2014-08-18 18:32:40 +02:00
|
|
|
package heroku
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
2014-09-28 20:51:39 +02:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2014-08-18 18:32:40 +02:00
|
|
|
"github.com/mitchellh/mapstructure"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
2014-09-28 20:51:39 +02:00
|
|
|
func Provider() terraform.ResourceProvider {
|
2014-08-18 18:32:40 +02:00
|
|
|
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-19 18:18:45 +02:00
|
|
|
"heroku_drain": resourceHerokuDrain(),
|
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()
|
|
|
|
}
|