github.com/andresvia/terraform@v0.6.15-0.20160412045437-d51c75946785/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 "consul_key_prefix": resourceConsulKeyPrefix(), 34 }, 35 36 ConfigureFunc: providerConfigure, 37 } 38 } 39 40 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 41 var config Config 42 configRaw := d.Get("").(map[string]interface{}) 43 if err := mapstructure.Decode(configRaw, &config); err != nil { 44 return nil, err 45 } 46 log.Printf("[INFO] Initializing Consul client") 47 return config.Client() 48 }