github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/builtin/providers/consul/resource_provider.go (about) 1 package consul 2 3 import ( 4 "log" 5 6 "github.com/hashicorp/terraform/helper/schema" 7 "github.com/hashicorp/terraform/terraform" 8 "github.com/mitchellh/mapstructure" 9 ) 10 11 // Provider returns a terraform.ResourceProvider. 12 func Provider() terraform.ResourceProvider { 13 return &schema.Provider{ 14 Schema: map[string]*schema.Schema{ 15 "datacenter": &schema.Schema{ 16 Type: schema.TypeString, 17 Optional: true, 18 }, 19 20 "address": &schema.Schema{ 21 Type: schema.TypeString, 22 Optional: true, 23 }, 24 25 "scheme": &schema.Schema{ 26 Type: schema.TypeString, 27 Optional: true, 28 }, 29 }, 30 31 ResourcesMap: map[string]*schema.Resource{ 32 "consul_keys": resourceConsulKeys(), 33 }, 34 35 ConfigureFunc: providerConfigure, 36 } 37 } 38 39 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 40 var config Config 41 configRaw := d.Get("").(map[string]interface{}) 42 if err := mapstructure.Decode(configRaw, &config); err != nil { 43 return nil, err 44 } 45 log.Printf("[INFO] Initializing Consul client") 46 return config.Client() 47 }