terraform/builtin/providers/heroku/provider.go

49 lines
1.2 KiB
Go
Raw Normal View History

package heroku
import (
"log"
"github.com/hashicorp/terraform/helper/schema"
2014-09-28 20:51:39 +02:00
"github.com/hashicorp/terraform/terraform"
)
// Provider returns a terraform.ResourceProvider.
2014-09-28 20:51:39 +02:00
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"email": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("HEROKU_EMAIL", nil),
},
"api_key": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("HEROKU_API_KEY", nil),
},
},
ResourcesMap: map[string]*schema.Resource{
"heroku_addon": resourceHerokuAddon(),
"heroku_app": resourceHerokuApp(),
"heroku_cert": resourceHerokuCert(),
"heroku_domain": resourceHerokuDomain(),
2014-08-19 18:18:45 +02:00
"heroku_drain": resourceHerokuDrain(),
"heroku_space": resourceHerokuSpace(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
Email: d.Get("email").(string),
APIKey: d.Get("api_key").(string),
}
log.Println("[INFO] Initializing Heroku client")
return config.Client()
}