2014-08-18 18:32:40 +02:00
|
|
|
package heroku
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
"github.com/mitchellh/mapstructure"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
|
|
|
func Provider() *schema.Provider {
|
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
|
|
"email": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
2014-08-19 00:18:51 +02:00
|
|
|
Optional: true,
|
2014-08-18 18:32:40 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
"api_key": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
2014-08-19 00:18:51 +02:00
|
|
|
Optional: true,
|
2014-08-18 18:32:40 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
2014-08-19 18:14:14 +02:00
|
|
|
"heroku_app": resourceHerokuApp(),
|
|
|
|
"heroku_addon": resourceHerokuAddon(),
|
|
|
|
"heroku_domain": resourceHerokuDomain(),
|
2014-08-18 18:32:40 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|