Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a resource for group attribute mapping #1850

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

IevaVasiljeva
Copy link
Contributor

@IevaVasiljeva IevaVasiljeva commented Oct 18, 2024

Adding a resource for group attribute mapping feature.

Requires grafana/grafana-openapi-client-go#103 to be merged first, so that we can bump the openAPI client dependency.

Here is an example of how the new resource can be used to map a role to a group:

resource "grafana_role" "report_admin_role" {
  name                   = "Report Administrator"
  uid                    = "report_admin_role_uid"
  auto_increment_version = true
  permissions {
    action = "reports:create"
  }
  permissions {
    action = "reports:read"
    scope  = "reports:*"
  }
}

resource "grafana_group_attribute_mapping" "report_admin_mapping" {
  group_id  = "business_dev_group_id"
  role_uids = [grafana_role.report_admin_role.uid]
}

Copy link

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@@ -42,14 +42,14 @@ var (
func(t *models.NotificationTemplate) string { return t.Name },
func(client *goapi.GrafanaHTTPAPI, id string) (*models.NotificationTemplate, error) {
resp, err := client.Provisioning.GetTemplate(id)
return payloadOrError(resp, err)
return payloadOrError[models.NotificationTemplate](resp, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't make it to automatically infer types, but I am not sure why. Let me know if you have any ideas.

Comment on lines 148 to 149
params := provisioning.NewDeleteTemplateParams().WithName(name)
_, err := client.Provisioning.DeleteTemplate(params)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the openAPI spec has changed slightly for alerting.

ID types.String `tfsdk:"id"`
OrgID types.String `tfsdk:"org_id"`
GroupID types.String `tfsdk:"group_id"`
RoleUIDs []types.String `tfsdk:"role_uids"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it should be types.Set instead. I don't find []types.String any other place.

@IevaVasiljeva
Copy link
Contributor Author

Waiting for #1905 to be merged (it updates the openAPI client dependency). Will then rebase on top of that and fix any remaining issues.

@IevaVasiljeva IevaVasiljeva requested a review from a team as a code owner November 20, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants