Skip to content

Commit c85ef17

Browse files
committed
Rewrite logic
1 parent be75f85 commit c85ef17

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

localdev/kubechecks/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
configMap:
22
create: true
33
env:
4+
GRPC_ENFORCE_ALPN_ENABLED: false
5+
KUBECHECKS_ALLOWED_NAMESPACES: httpbin,httpdump-a
46
KUBECHECKS_LOG_LEVEL: debug
57
KUBECHECKS_ENABLE_WEBHOOK_CONTROLLER: "false"
68
KUBECHECKS_ARGOCD_API_INSECURE: "true"

pkg/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ func NewWithViper(v *viper.Viper) (ServerConfig, error) {
105105
return time.ParseDuration(input)
106106
}
107107

108+
if in.String() == "string" && out.String() == "[]string" {
109+
input := value.(string)
110+
return []string{input}, nil
111+
}
112+
108113
return value, nil
109114
}
110115
}); err != nil {

pkg/events/check.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,11 @@ func (ce *CheckEvent) Process(ctx context.Context) error {
292292
ce.logger.Info().Msgf("adding %d apps to the queue", len(ce.affectedItems.Applications))
293293
// Produce apps onto channel
294294
for _, app := range ce.affectedItems.Applications {
295-
if len(ce.ctr.Config.AllowedNamespaces) > 0 {
296-
ns := strings.Split(ce.ctr.Config.AllowedNamespaces[0], ",")
297-
if slices.Contains(ns, app.Spec.Destination.Namespace) {
298-
ce.queueApp(app)
299-
} else {
300-
ce.logger.Info().Msgf("skipping app %s, namespace %s not allowed", app.Name, app.Spec.Destination.Namespace)
301-
}
302-
} else {
303-
ce.queueApp(app)
295+
if len(ce.ctr.Config.AllowedNamespaces) > 0 && !slices.Contains(ce.ctr.Config.AllowedNamespaces, app.Spec.Destination.Namespace) {
296+
ce.logger.Info().Msgf("skipping app %s, namespace %s not allowed", app.Name, app.Spec.Destination.Namespace)
297+
continue
304298
}
299+
ce.queueApp(app)
305300
}
306301

307302
ce.wg.Wait()

0 commit comments

Comments
 (0)