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

     1  package packet
     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 managing Packet infrastructure.
     9  func Provider() terraform.ResourceProvider {
    10  	return &schema.Provider{
    11  		Schema: map[string]*schema.Schema{
    12  			"auth_token": &schema.Schema{
    13  				Type:        schema.TypeString,
    14  				Required:    true,
    15  				DefaultFunc: schema.EnvDefaultFunc("PACKET_AUTH_TOKEN", nil),
    16  				Description: "The API auth key for API operations.",
    17  			},
    18  		},
    19  
    20  		ResourcesMap: map[string]*schema.Resource{
    21  			"packet_device":  resourcePacketDevice(),
    22  			"packet_ssh_key": resourcePacketSSHKey(),
    23  			"packet_project": resourcePacketProject(),
    24  			"packet_volume":  resourcePacketVolume(),
    25  		},
    26  
    27  		ConfigureFunc: providerConfigure,
    28  	}
    29  }
    30  
    31  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    32  	config := Config{
    33  		AuthToken: d.Get("auth_token").(string),
    34  	}
    35  	return config.Client(), nil
    36  }