github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/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 Packet.
     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  		},
    25  
    26  		ConfigureFunc: providerConfigure,
    27  	}
    28  }
    29  
    30  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    31  	config := Config{
    32  		AuthToken: d.Get("auth_token").(string),
    33  	}
    34  
    35  	return config.Client(), nil
    36  }