From 017448fc94787423706f7970c3d990d2a9a1a303 Mon Sep 17 00:00:00 2001 From: David Gubler Date: Tue, 13 Feb 2024 08:38:13 +0100 Subject: [PATCH] fix: Clear auto_assign_org last to improve user experience on Grafana (#13) --- pkg/reconcile.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/reconcile.go b/pkg/reconcile.go index 40a32b8..be7b41e 100644 --- a/pkg/reconcile.go +++ b/pkg/reconcile.go @@ -68,6 +68,18 @@ outAdmins: } klog.Infof("Found %d admin users", len(keycloakAdmins)) + grafanaOrgsMap, err := reconcileAllOrgs(ctx, config, keycloakOrganizations, grafanaClient, dashboards) + if err != nil { + return err + } + + klog.Infof("Checking permissions of normal orgs...") + grafanaPermissionsMap := getGrafanaPermissionsMap(keycloakUserGroups, keycloakAdmins, keycloakOrganizations) + err = reconcilePermissions(ctx, grafanaPermissionsMap, grafanaOrgsMap, grafanaClient) + if err != nil { + return err + } + if config.GrafanaClearAutoAssignOrg { klog.Infof("Fetching auto_assign_org_id...") autoAssignOrgId, err := grafanaClient.GetAutoAssignOrgId() @@ -82,18 +94,6 @@ outAdmins: } } - grafanaOrgsMap, err := reconcileAllOrgs(ctx, config, keycloakOrganizations, grafanaClient, dashboards) - if err != nil { - return err - } - - klog.Infof("Checking permissions of normal orgs...") - grafanaPermissionsMap := getGrafanaPermissionsMap(keycloakUserGroups, keycloakAdmins, keycloakOrganizations) - err = reconcilePermissions(ctx, grafanaPermissionsMap, grafanaOrgsMap, grafanaClient) - if err != nil { - return err - } - grafanaClient.CloseIdleConnections() keycloakClient.CloseIdleConnections()