github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/heroku/provider.go (about)

     1  package heroku
     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  			"email": &schema.Schema{
    15  				Type:        schema.TypeString,
    16  				Optional:    true,
    17  				DefaultFunc: schema.EnvDefaultFunc("HEROKU_EMAIL", nil),
    18  			},
    19  
    20  			"api_key": &schema.Schema{
    21  				Type:        schema.TypeString,
    22  				Optional:    true,
    23  				DefaultFunc: schema.EnvDefaultFunc("HEROKU_API_KEY", nil),
    24  			},
    25  		},
    26  
    27  		ResourcesMap: map[string]*schema.Resource{
    28  			"heroku_addon":  resourceHerokuAddon(),
    29  			"heroku_app":    resourceHerokuApp(),
    30  			"heroku_cert":   resourceHerokuCert(),
    31  			"heroku_domain": resourceHerokuDomain(),
    32  			"heroku_drain":  resourceHerokuDrain(),
    33  			"heroku_space":  resourceHerokuSpace(),
    34  		},
    35  
    36  		ConfigureFunc: providerConfigure,
    37  	}
    38  }
    39  
    40  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    41  	config := Config{
    42  		Email:  d.Get("email").(string),
    43  		APIKey: d.Get("api_key").(string),
    44  	}
    45  
    46  	log.Println("[INFO] Initializing Heroku client")
    47  	return config.Client()
    48  }