github.com/mohanarpit/terraform@v0.6.16-0.20160909104007-291f29853544/builtin/providers/powerdns/provider.go (about)

     1  package powerdns
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/schema"
     5  	"github.com/hashicorp/terraform/terraform"
     6  )
     7  
     8  func Provider() terraform.ResourceProvider {
     9  	return &schema.Provider{
    10  		Schema: map[string]*schema.Schema{
    11  			"api_key": {
    12  				Type:        schema.TypeString,
    13  				Required:    true,
    14  				DefaultFunc: schema.EnvDefaultFunc("PDNS_API_KEY", nil),
    15  				Description: "REST API authentication key",
    16  			},
    17  			"server_url": {
    18  				Type:        schema.TypeString,
    19  				Required:    true,
    20  				DefaultFunc: schema.EnvDefaultFunc("PDNS_SERVER_URL", nil),
    21  				Description: "Location of PowerDNS server",
    22  			},
    23  		},
    24  
    25  		ResourcesMap: map[string]*schema.Resource{
    26  			"powerdns_record": resourcePDNSRecord(),
    27  		},
    28  
    29  		ConfigureFunc: providerConfigure,
    30  	}
    31  }
    32  
    33  func providerConfigure(data *schema.ResourceData) (interface{}, error) {
    34  	config := Config{
    35  		ApiKey:    data.Get("api_key").(string),
    36  		ServerUrl: data.Get("server_url").(string),
    37  	}
    38  
    39  	return config.Client()
    40  }