github.com/pmcatominey/terraform@v0.7.0-rc2.0.20160708105029-1401a52a5cc5/builtin/providers/librato/provider.go (about)

     1  package librato
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/schema"
     5  	"github.com/hashicorp/terraform/terraform"
     6  	"github.com/henrikhodne/go-librato/librato"
     7  )
     8  
     9  // Provider returns a schema.Provider for Librato.
    10  func Provider() terraform.ResourceProvider {
    11  	return &schema.Provider{
    12  		Schema: map[string]*schema.Schema{
    13  			"email": &schema.Schema{
    14  				Type:        schema.TypeString,
    15  				Required:    true,
    16  				DefaultFunc: schema.EnvDefaultFunc("LIBRATO_EMAIL", nil),
    17  				Description: "The email address for the Librato account.",
    18  			},
    19  
    20  			"token": &schema.Schema{
    21  				Type:        schema.TypeString,
    22  				Required:    true,
    23  				DefaultFunc: schema.EnvDefaultFunc("LIBRATO_TOKEN", nil),
    24  				Description: "The auth token for the Librato account.",
    25  			},
    26  		},
    27  
    28  		ResourcesMap: map[string]*schema.Resource{
    29  			"librato_space":       resourceLibratoSpace(),
    30  			"librato_space_chart": resourceLibratoSpaceChart(),
    31  		},
    32  
    33  		ConfigureFunc: providerConfigure,
    34  	}
    35  }
    36  
    37  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    38  	client := librato.NewClient(d.Get("email").(string), d.Get("token").(string))
    39  
    40  	return client, nil
    41  }