github.com/chalford/terraform@v0.3.7-0.20150113080010-a78c69a8c81f/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 26 ResourcesMap: map[string]*schema.Resource{ 27 "consul_keys": resourceConsulKeys(), 28 }, 29 30 ConfigureFunc: providerConfigure, 31 } 32 } 33 34 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 35 var config Config 36 configRaw := d.Get("").(map[string]interface{}) 37 if err := mapstructure.Decode(configRaw, &config); err != nil { 38 return nil, err 39 } 40 log.Printf("[INFO] Initializing Consul client") 41 return config.Client() 42 }