terraform/builtin/providers/dnsimple/provider.go

43 lines
1.0 KiB
Go
Raw Normal View History

package dnsimple
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
// Provider returns a terraform.ResourceProvider.
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"email": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("DNSIMPLE_EMAIL", nil),
Description: "A registered DNSimple email address.",
},
"token": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("DNSIMPLE_TOKEN", nil),
Description: "The token key for API operations.",
},
},
ResourcesMap: map[string]*schema.Resource{
"dnsimple_record": resourceDNSimpleRecord(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
Email: d.Get("email").(string),
Token: d.Get("token").(string),
}
return config.Client()
}