github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/ultradns/provider.go (about)

     1  package ultradns
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/schema"
     5  	"github.com/hashicorp/terraform/terraform"
     6  )
     7  
     8  // Provider returns a terraform.ResourceProvider.
     9  func Provider() terraform.ResourceProvider {
    10  	return &schema.Provider{
    11  		Schema: map[string]*schema.Schema{
    12  			"username": &schema.Schema{
    13  				Type:        schema.TypeString,
    14  				Required:    true,
    15  				DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_USERNAME", nil),
    16  				Description: "UltraDNS Username.",
    17  			},
    18  
    19  			"password": &schema.Schema{
    20  				Type:        schema.TypeString,
    21  				Required:    true,
    22  				DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_PASSWORD", nil),
    23  				Description: "UltraDNS User Password",
    24  			},
    25  			"baseurl": &schema.Schema{
    26  				Type:        schema.TypeString,
    27  				Required:    true,
    28  				DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_BASEURL", nil),
    29  				Description: "UltraDNS Base Url(defaults to testing)",
    30  			},
    31  		},
    32  
    33  		ResourcesMap: map[string]*schema.Resource{
    34  			"ultradns_record": resourceUltraDNSRecord(),
    35  		},
    36  
    37  		ConfigureFunc: providerConfigure,
    38  	}
    39  }
    40  
    41  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    42  	config := Config{
    43  		Username: d.Get("username").(string),
    44  		Password: d.Get("password").(string),
    45  		BaseURL:  d.Get("baseurl").(string),
    46  	}
    47  
    48  	return config.Client()
    49  }