terraform/builtin/providers/ultradns/provider.go

50 lines
1.3 KiB
Go
Raw Normal View History

2015-07-04 10:26:13 +02:00
package ultradns
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{
"username": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_USERNAME", nil),
Description: "UltraDNS Username.",
},
"password": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_PASSWORD", nil),
Description: "UltraDNS User Password",
},
"baseurl": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_BASEURL", nil),
Description: "UltraDNS Base Url(defaults to testing)",
},
},
ResourcesMap: map[string]*schema.Resource{
"ultradns_record": resourceUltraDNSRecord(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
Username: d.Get("username").(string),
Password: d.Get("password").(string),
BaseURL: d.Get("baseurl").(string),
}
return config.Client()
}