github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/dyn/provider.go (about)

     1  package dyn
     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  			"customer_name": &schema.Schema{
    13  				Type:        schema.TypeString,
    14  				Required:    true,
    15  				DefaultFunc: schema.EnvDefaultFunc("DYN_CUSTOMER_NAME", nil),
    16  				Description: "A Dyn customer name.",
    17  			},
    18  
    19  			"username": &schema.Schema{
    20  				Type:        schema.TypeString,
    21  				Required:    true,
    22  				DefaultFunc: schema.EnvDefaultFunc("DYN_USERNAME", nil),
    23  				Description: "A Dyn username.",
    24  			},
    25  
    26  			"password": &schema.Schema{
    27  				Type:        schema.TypeString,
    28  				Required:    true,
    29  				DefaultFunc: schema.EnvDefaultFunc("DYN_PASSWORD", nil),
    30  				Description: "The Dyn password.",
    31  			},
    32  		},
    33  
    34  		ResourcesMap: map[string]*schema.Resource{
    35  			"dyn_record": resourceDynRecord(),
    36  		},
    37  
    38  		ConfigureFunc: providerConfigure,
    39  	}
    40  }
    41  
    42  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    43  	config := Config{
    44  		CustomerName: d.Get("customer_name").(string),
    45  		Username:     d.Get("username").(string),
    46  		Password:     d.Get("password").(string),
    47  	}
    48  
    49  	return config.Client()
    50  }