github.com/richardbowden/terraform@v0.6.12-0.20160901200758-30ea22c25211/builtin/providers/digitalocean/provider.go (about)

     1  package digitalocean
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/schema"
     5  	"github.com/hashicorp/terraform/terraform"
     6  )
     7  
     8  // Provider returns a schema.Provider for DigitalOcean.
     9  func Provider() terraform.ResourceProvider {
    10  	return &schema.Provider{
    11  		Schema: map[string]*schema.Schema{
    12  			"token": &schema.Schema{
    13  				Type:        schema.TypeString,
    14  				Required:    true,
    15  				DefaultFunc: schema.EnvDefaultFunc("DIGITALOCEAN_TOKEN", nil),
    16  				Description: "The token key for API operations.",
    17  			},
    18  		},
    19  
    20  		ResourcesMap: map[string]*schema.Resource{
    21  			"digitalocean_domain":      resourceDigitalOceanDomain(),
    22  			"digitalocean_droplet":     resourceDigitalOceanDroplet(),
    23  			"digitalocean_floating_ip": resourceDigitalOceanFloatingIp(),
    24  			"digitalocean_record":      resourceDigitalOceanRecord(),
    25  			"digitalocean_ssh_key":     resourceDigitalOceanSSHKey(),
    26  			"digitalocean_tag":         resourceDigitalOceanTag(),
    27  			"digitalocean_volume":      resourceDigitalOceanVolume(),
    28  		},
    29  
    30  		ConfigureFunc: providerConfigure,
    31  	}
    32  }
    33  
    34  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    35  	config := Config{
    36  		Token: d.Get("token").(string),
    37  	}
    38  
    39  	return config.Client()
    40  }