From 5a1ce4457811166bc776bd1dcc82c4f989d47fb5 Mon Sep 17 00:00:00 2001 From: Francis Chuang Date: Wed, 3 Apr 2024 15:41:47 +1100 Subject: [PATCH] Set service account role to "None" if no role is provided --- path_credentials.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/path_credentials.go b/path_credentials.go index aedbf90..72e9a50 100644 --- a/path_credentials.go +++ b/path_credentials.go @@ -164,9 +164,14 @@ func createCloudAccessPolicyToken(c *client.Grafana, credentialName string, role } func createCloudServiceAccountToken(c *client.Grafana, credentialName string, roleEntry *grafanaRoleEntry) (*grafanaToken, error) { + role := "None" + if roleEntry.Role != "" { + role = roleEntry.Role + } + serviceAccount, err := c.CreateGrafanaServiceAccountFromCloud(roleEntry.Stack, client.CreateServiceAccountInput{ Name: credentialName, - Role: roleEntry.Role, + Role: role, }) if err != nil { @@ -197,9 +202,14 @@ func createCloudServiceAccountToken(c *client.Grafana, credentialName string, ro } func createServiceAccountToken(c *client.Grafana, credentialName string, roleEntry *grafanaRoleEntry) (*grafanaToken, error) { + role := "None" + if roleEntry.Role != "" { + role = roleEntry.Role + } + serviceAccount, err := c.CreateServiceAccount(client.CreateServiceAccountInput{ Name: credentialName, - Role: roleEntry.Role, + Role: role, }) if err != nil {