github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/ultradns/provider.go (about)

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