terraform/builtin/providers/heroku/provider.go

48 lines
1.1 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_app": resourceHerokuApp(),
"heroku_addon": resourceHerokuAddon(),
"heroku_domain": resourceHerokuDomain(),
2014-08-19 18:18:45 +02:00
"heroku_drain": resourceHerokuDrain(),
"heroku_cert": resourceHerokuCert(),
},
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()
}