Skip to content

Commit

Permalink
Add check AMRs are being watched before initialising cache
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardDowling committed Sep 26, 2024
1 parent bca7118 commit 67b9c80
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions integrations/access/pagerduty/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"errors"
"fmt"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -152,8 +153,17 @@ func (a *App) run(ctx context.Context) error {
if err != nil {
return trace.Wrap(err)
}
if err := a.accessMonitoringRules.InitAccessMonitoringRulesCache(ctx); err != nil {
return trace.Wrap(err)

if len(acceptedWatchKinds) == 0 {
return trace.BadParameter("failed to initialize watcher for all the required resources: %+v",
watchKinds)
}
// Check if KindAccessMonitoringRule resources are being watched,
// the role the plugin is running as may not have access.
if slices.Contains(acceptedWatchKinds, types.KindAccessMonitoringRule) {
if err := a.accessMonitoringRules.InitAccessMonitoringRulesCache(ctx); err != nil {
return trace.Wrap(err, "initializing Access Monitoring Rule cache")
}
}

a.mainJob.SetReady(ok)
Expand Down

0 comments on commit 67b9c80

Please sign in to comment.