github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/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": {
    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  		DataSourcesMap: map[string]*schema.Resource{
    21  			"digitalocean_image": dataSourceDigitalOceanImage(),
    22  		},
    23  
    24  		ResourcesMap: map[string]*schema.Resource{
    25  			"digitalocean_domain":       resourceDigitalOceanDomain(),
    26  			"digitalocean_droplet":      resourceDigitalOceanDroplet(),
    27  			"digitalocean_floating_ip":  resourceDigitalOceanFloatingIp(),
    28  			"digitalocean_loadbalancer": resourceDigitalOceanLoadbalancer(),
    29  			"digitalocean_record":       resourceDigitalOceanRecord(),
    30  			"digitalocean_ssh_key":      resourceDigitalOceanSSHKey(),
    31  			"digitalocean_tag":          resourceDigitalOceanTag(),
    32  			"digitalocean_volume":       resourceDigitalOceanVolume(),
    33  		},
    34  
    35  		ConfigureFunc: providerConfigure,
    36  	}
    37  }
    38  
    39  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    40  	config := Config{
    41  		Token: d.Get("token").(string),
    42  	}
    43  
    44  	return config.Client()
    45  }