github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/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  			"librato_metric":      resourceLibratoMetric(),
    32  			"librato_alert":       resourceLibratoAlert(),
    33  			"librato_service":     resourceLibratoService(),
    34  		},
    35  
    36  		ConfigureFunc: providerConfigure,
    37  	}
    38  }
    39  
    40  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    41  	client := librato.NewClient(d.Get("email").(string), d.Get("token").(string))
    42  
    43  	return client, nil
    44  }