Skip to content

Commit

Permalink
Rewrite logic
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi-kapoor committed Dec 9, 2024
1 parent be75f85 commit c85ef17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions localdev/kubechecks/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
configMap:
create: true
env:
GRPC_ENFORCE_ALPN_ENABLED: false
KUBECHECKS_ALLOWED_NAMESPACES: httpbin,httpdump-a
KUBECHECKS_LOG_LEVEL: debug
KUBECHECKS_ENABLE_WEBHOOK_CONTROLLER: "false"
KUBECHECKS_ARGOCD_API_INSECURE: "true"
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func NewWithViper(v *viper.Viper) (ServerConfig, error) {
return time.ParseDuration(input)
}

if in.String() == "string" && out.String() == "[]string" {
input := value.(string)
return []string{input}, nil
}

return value, nil
}
}); err != nil {
Expand Down
13 changes: 4 additions & 9 deletions pkg/events/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,11 @@ func (ce *CheckEvent) Process(ctx context.Context) error {
ce.logger.Info().Msgf("adding %d apps to the queue", len(ce.affectedItems.Applications))
// Produce apps onto channel
for _, app := range ce.affectedItems.Applications {
if len(ce.ctr.Config.AllowedNamespaces) > 0 {
ns := strings.Split(ce.ctr.Config.AllowedNamespaces[0], ",")
if slices.Contains(ns, app.Spec.Destination.Namespace) {
ce.queueApp(app)
} else {
ce.logger.Info().Msgf("skipping app %s, namespace %s not allowed", app.Name, app.Spec.Destination.Namespace)
}
} else {
ce.queueApp(app)
if len(ce.ctr.Config.AllowedNamespaces) > 0 && !slices.Contains(ce.ctr.Config.AllowedNamespaces, app.Spec.Destination.Namespace) {
ce.logger.Info().Msgf("skipping app %s, namespace %s not allowed", app.Name, app.Spec.Destination.Namespace)
continue
}
ce.queueApp(app)
}

ce.wg.Wait()
Expand Down

0 comments on commit c85ef17

Please sign in to comment.