mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-15 19:22:46 -06:00
158a90b25b
* Grafana provider * grafana_data_source resource. Allows data sources to be created in Grafana. Supports all data source types that are accepted in the current version of Grafana, and will support any future ones that fit into the existing structure. * Vendoring of apparentlymart/go-grafana-api This is in anticipation of adding a Grafana provider plugin. * grafana_dashboard resource * Website documentation for the Grafana provider.
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package grafana
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
gapi "github.com/apparentlymart/go-grafana-api"
|
|
)
|
|
|
|
func Provider() terraform.ResourceProvider {
|
|
return &schema.Provider{
|
|
Schema: map[string]*schema.Schema{
|
|
"url": &schema.Schema{
|
|
Type: schema.TypeString,
|
|
Required: true,
|
|
DefaultFunc: schema.EnvDefaultFunc("GRAFANA_URL", nil),
|
|
Description: "URL of the root of the target Grafana server.",
|
|
},
|
|
"auth": &schema.Schema{
|
|
Type: schema.TypeString,
|
|
Required: true,
|
|
DefaultFunc: schema.EnvDefaultFunc("GRAFANA_AUTH", nil),
|
|
Description: "Credentials for accessing the Grafana API.",
|
|
},
|
|
},
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
|
"grafana_dashboard": ResourceDashboard(),
|
|
"grafana_data_source": ResourceDataSource(),
|
|
},
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
}
|
|
}
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
return gapi.New(
|
|
d.Get("auth").(string),
|
|
d.Get("url").(string),
|
|
)
|
|
}
|