github.com/maheshbr/terraform@v0.3.1-0.20141020033300-deec7194a3ea/builtin/providers/mailgun/provider.go (about) 1 package mailgun 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 "api_key": &schema.Schema{ 16 Type: schema.TypeString, 17 Required: true, 18 }, 19 }, 20 21 ResourcesMap: map[string]*schema.Resource{ 22 "mailgun_domain": resourceMailgunDomain(), 23 }, 24 25 ConfigureFunc: providerConfigure, 26 } 27 } 28 29 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 30 var config Config 31 configRaw := d.Get("").(map[string]interface{}) 32 if err := mapstructure.Decode(configRaw, &config); err != nil { 33 return nil, err 34 } 35 36 log.Println("[INFO] Initializing Mailgun client") 37 38 return config.Client() 39 }