github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/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  )
     9  
    10  // Provider returns a terraform.ResourceProvider.
    11  func Provider() terraform.ResourceProvider {
    12  	return &schema.Provider{
    13  		Schema: map[string]*schema.Schema{
    14  			"api_key": &schema.Schema{
    15  				Type:        schema.TypeString,
    16  				Required:    true,
    17  				DefaultFunc: schema.EnvDefaultFunc("MAILGUN_API_KEY", nil),
    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  	config := Config{
    31  		APIKey: d.Get("api_key").(string),
    32  	}
    33  
    34  	log.Println("[INFO] Initializing Mailgun client")
    35  	return config.Client()
    36  }