2014-09-09 22:13:11 +02:00
|
|
|
package digitalocean
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
2014-11-17 18:55:45 +01:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2014-09-09 22:13:11 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a schema.Provider for DigitalOcean.
|
2014-11-17 18:55:45 +01:00
|
|
|
func Provider() terraform.ResourceProvider {
|
2014-09-09 22:13:11 +02:00
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
|
|
"token": &schema.Schema{
|
2014-11-17 18:55:45 +01:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
2015-01-16 18:22:09 +01:00
|
|
|
DefaultFunc: schema.EnvDefaultFunc("DIGITALOCEAN_TOKEN", nil),
|
2014-11-17 18:55:45 +01:00
|
|
|
Description: "The token key for API operations.",
|
2014-09-09 22:13:11 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2014-09-09 22:29:36 +02:00
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
2014-11-17 18:55:45 +01:00
|
|
|
"digitalocean_domain": resourceDigitalOceanDomain(),
|
|
|
|
"digitalocean_droplet": resourceDigitalOceanDroplet(),
|
|
|
|
"digitalocean_record": resourceDigitalOceanRecord(),
|
2015-02-25 12:38:23 +01:00
|
|
|
"digitalocean_ssh_key": resourceDigitalOceanSSHKey(),
|
2014-09-09 22:29:36 +02:00
|
|
|
},
|
2014-11-17 18:55:45 +01:00
|
|
|
|
|
|
|
ConfigureFunc: providerConfigure,
|
2014-09-09 22:13:11 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-17 18:55:45 +01:00
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
|
|
|
Token: d.Get("token").(string),
|
|
|
|
}
|
|
|
|
|
|
|
|
return config.Client()
|
|
|
|
}
|