Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions grafana/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ func Provider(version string) func() *schema.Provider {
DefaultFunc: schema.EnvDefaultFunc("GRAFANA_AUTH", nil),
Description: "API token or basic auth username:password. May alternatively be set via the `GRAFANA_AUTH` environment variable.",
},
"proxy_auth": {
Type: schema.TypeString,
Required: false,
Sensitive: true,
DefaultFunc: schema.EnvDefaultFunc("GRAFANA_PROXY_AUTH", nil),
Description: "API token. May alternatively be set via the `GRAFANA_PROXY_AUTH` environment variable.",
},
"org_id": {
Type: schema.TypeInt,
Required: true,
Expand Down Expand Up @@ -140,6 +147,11 @@ func configure(version string, p *schema.Provider) func(context.Context, *schema
c := &client{}

auth := strings.SplitN(d.Get("auth").(string), ":", 2)
pa := d.Get("proxy_auth")
var proxyAuth string
if pa != nil {
proxyAuth = d.Get("proxy_auth").(string)
}
cli := cleanhttp.DefaultClient()
transport := cleanhttp.DefaultTransport()
transport.TLSClientConfig = &tls.Config{}
Expand Down Expand Up @@ -179,6 +191,9 @@ func configure(version string, p *schema.Provider) func(context.Context, *schema
} else {
cfg.APIKey = auth[0]
}
if proxyAuth != "" {
cfg.Proxy.APIKey = proxyAuth
}
gclient, err := gapi.New(d.Get("url").(string), cfg)
if err != nil {
return nil, diag.FromErr(err)
Expand Down