github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/grafana/provider.go (about)

     1  package grafana
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/schema"
     5  	"github.com/hashicorp/terraform/terraform"
     6  
     7  	gapi "github.com/apparentlymart/go-grafana-api"
     8  )
     9  
    10  func Provider() terraform.ResourceProvider {
    11  	return &schema.Provider{
    12  		Schema: map[string]*schema.Schema{
    13  			"url": &schema.Schema{
    14  				Type:        schema.TypeString,
    15  				Required:    true,
    16  				DefaultFunc: schema.EnvDefaultFunc("GRAFANA_URL", nil),
    17  				Description: "URL of the root of the target Grafana server.",
    18  			},
    19  			"auth": &schema.Schema{
    20  				Type:        schema.TypeString,
    21  				Required:    true,
    22  				DefaultFunc: schema.EnvDefaultFunc("GRAFANA_AUTH", nil),
    23  				Description: "Credentials for accessing the Grafana API.",
    24  			},
    25  		},
    26  
    27  		ResourcesMap: map[string]*schema.Resource{
    28  			"grafana_dashboard":   ResourceDashboard(),
    29  			"grafana_data_source": ResourceDataSource(),
    30  		},
    31  
    32  		ConfigureFunc: providerConfigure,
    33  	}
    34  }
    35  
    36  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    37  	return gapi.New(
    38  		d.Get("auth").(string),
    39  		d.Get("url").(string),
    40  	)
    41  }