github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/builtin/providers/dnsimple/provider.go (about)

     1  package dnsimple
     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  			"email": &schema.Schema{
    13  				Type:        schema.TypeString,
    14  				Required:    true,
    15  				DefaultFunc: schema.EnvDefaultFunc("DNSIMPLE_EMAIL", nil),
    16  				Description: "A registered DNSimple email address.",
    17  			},
    18  
    19  			"token": &schema.Schema{
    20  				Type:        schema.TypeString,
    21  				Required:    true,
    22  				DefaultFunc: schema.EnvDefaultFunc("DNSIMPLE_TOKEN", nil),
    23  				Description: "The token key for API operations.",
    24  			},
    25  		},
    26  
    27  		ResourcesMap: map[string]*schema.Resource{
    28  			"dnsimple_record": resourceDNSimpleRecord(),
    29  		},
    30  
    31  		ConfigureFunc: providerConfigure,
    32  	}
    33  }
    34  
    35  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    36  	config := Config{
    37  		Email: d.Get("email").(string),
    38  		Token: d.Get("token").(string),
    39  	}
    40  
    41  	return config.Client()
    42  }