terraform/builtin/providers/heroku/provider.go

47 lines
1.0 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"
"github.com/mitchellh/mapstructure"
)
// 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,
2014-08-19 00:18:51 +02:00
Optional: true,
},
"api_key": &schema.Schema{
Type: schema.TypeString,
2014-08-19 00:18:51 +02:00
Optional: true,
},
},
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(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
var config Config
configRaw := d.Get("").(map[string]interface{})
if err := mapstructure.Decode(configRaw, &config); err != nil {
return nil, err
}
log.Println("[INFO] Initializing Heroku client")
return config.Client()
}