From a9d100048d22c39aaee1d44d4fc3a0b7a5f3b710 Mon Sep 17 00:00:00 2001 From: Matias Bordese Date: Fri, 13 Jun 2025 15:15:23 -0300 Subject: [PATCH] oncall: show warning about switching to irm perms/roles --- internal/resources/grafana/data_source_role.go | 8 ++++++++ internal/resources/grafana/resource_role.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/resources/grafana/data_source_role.go b/internal/resources/grafana/data_source_role.go index 07a9b1745..d8811df5d 100644 --- a/internal/resources/grafana/data_source_role.go +++ b/internal/resources/grafana/data_source_role.go @@ -2,6 +2,7 @@ package grafana import ( "context" + "strings" "github.com/grafana/grafana-openapi-client-go/client/access_control" "github.com/grafana/terraform-provider-grafana/v3/internal/common" @@ -23,6 +24,13 @@ func datasourceRole() *common.DataSource { Type: schema.TypeString, Required: true, Description: "Name of the role", + ValidateFunc: func(i interface{}, k string) (warnings []string, errors []error) { + name := i.(string) + if strings.HasPrefix(strings.ToLower(name), "plugins:grafana-oncall-app:") { + warnings = append(warnings, "Roles from 'grafana-oncall-app' are deprecated and should be migrated to 'grafana-irm-app' roles instead.") + } + return warnings, nil + }, }, "auto_increment_version": nil, }), diff --git a/internal/resources/grafana/resource_role.go b/internal/resources/grafana/resource_role.go index 6a977aea5..03e375a50 100644 --- a/internal/resources/grafana/resource_role.go +++ b/internal/resources/grafana/resource_role.go @@ -2,6 +2,7 @@ package grafana import ( "context" + "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -94,6 +95,13 @@ func resourceRole() *common.Resource { Type: schema.TypeString, Required: true, Description: "Specific action users granted with the role will be allowed to perform (for example: `users:read`)", + ValidateFunc: func(i interface{}, k string) (warnings []string, errors []error) { + action := i.(string) + if strings.HasPrefix(action, "grafana-oncall-app.") { + warnings = append(warnings, "'grafana-oncall-app' permissions are deprecated. Permissions from 'grafana-oncall-app' should be migrated to the corresponding 'grafana-irm-app' permissions.") + } + return warnings, nil + }, }, "scope": { Type: schema.TypeString,