Skip to content

Commit 5fd293e

Browse files
Silence org_id deprecation warning when not using it (#984)
The default value is making Terraform complain even if `org_id` isn't specified
1 parent b1eafa3 commit 5fd293e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/provider/provider.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func Provider(version string) func() *schema.Provider {
198198
Type: schema.TypeInt,
199199
Optional: true,
200200
Deprecated: "Use the `org_id` attributes on resources instead.",
201-
DefaultFunc: schema.EnvDefaultFunc("GRAFANA_ORG_ID", 1),
201+
DefaultFunc: schema.EnvDefaultFunc("GRAFANA_ORG_ID", nil),
202202
Description: "Deprecated: Use the `org_id` attributes on resources instead.",
203203
},
204204
"tls_key": {
@@ -410,7 +410,10 @@ func createGrafanaClient(d *schema.ResourceData) (string, *gapi.Config, *gapi.Cl
410410
if v, ok := d.GetOk("retry_status_codes"); ok {
411411
cfg.RetryStatusCodes = common.SetToStringSlice(v.(*schema.Set))
412412
}
413-
orgID := d.Get("org_id").(int)
413+
orgID := 1
414+
if v, ok := d.GetOk("org_id"); ok {
415+
orgID = v.(int)
416+
}
414417
if len(auth) == 2 {
415418
cfg.BasicAuth = url.UserPassword(auth[0], auth[1])
416419
cfg.OrgID = int64(orgID)

0 commit comments

Comments
 (0)