Skip to content

Commit

Permalink
Fix incorrect IDs being used to lookup user permissions during sync (#…
Browse files Browse the repository at this point in the history
…4931)

# What this PR does
- Fixes ID being used to lookup user permissions during sync.
- Reduce level on overly chatty log message

## Which issue(s) this PR closes

Related to [issue link here]

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
  • Loading branch information
mderynck authored Aug 26, 2024
1 parent 9655a90 commit 3269c9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions grafana-plugin/pkg/plugin/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ func (a *App) OnCallSettingsFromContext(ctx context.Context) (*OnCallPluginSetti
return &settings, fmt.Errorf("get GrafanaURL from provisioning failed (not set in jsonData), unable to fallback to grafana cfg")
}
settings.GrafanaURL = appUrl
log.DefaultLogger.Info(fmt.Sprintf("Using Grafana URL from grafana cfg app url: %s", settings.GrafanaURL))
log.DefaultLogger.Debug(fmt.Sprintf("Using Grafana URL from grafana cfg app url: %s", settings.GrafanaURL))
} else {
log.DefaultLogger.Info(fmt.Sprintf("Using Grafana URL from provisioning: %s", settings.GrafanaURL))
log.DefaultLogger.Debug(fmt.Sprintf("Using Grafana URL from provisioning: %s", settings.GrafanaURL))
}

settings.RBACEnabled = cfg.FeatureToggles().IsEnabled("accessControlOnCall")
Expand Down
6 changes: 4 additions & 2 deletions grafana-plugin/pkg/plugin/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"net/url"
"sort"
"strconv"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -264,14 +265,15 @@ func (a *App) GetAllUsersWithPermissions(settings *OnCallPluginSettings) ([]OnCa
return nil, err
}
for i := range onCallUsers {
actions, exists := permissions["1"]
userId := strconv.Itoa(onCallUsers[i].ID)
actions, exists := permissions[userId]
if exists {
onCallUsers[i].Permissions = []OnCallPermission{}
for action, _ := range actions {
onCallUsers[i].Permissions = append(onCallUsers[i].Permissions, OnCallPermission{Action: action})
}
} else {
log.DefaultLogger.Error("Did not find permissions for user", "user", onCallUsers[i].Login)
log.DefaultLogger.Error("Did not find permissions for user", "user", onCallUsers[i].Login, "id", userId)
}
}
}
Expand Down

0 comments on commit 3269c9b

Please sign in to comment.