From 0d7f22fcf5475fdf6b3bda79e776bb23b11c3ff9 Mon Sep 17 00:00:00 2001 From: Yunus Sandikci Date: Thu, 25 Apr 2024 20:55:26 +0300 Subject: [PATCH] Fix secret merge issue. --- .golangci.yaml | 3 +++ cmd/manager/main.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 94033ac..8fc206c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -12,6 +12,9 @@ linters: - gochecknoglobals # We like global variables - tagalign # Buggy linters-settings: + gosec: + excludes: + - 'G601' cyclop: max-complexity: 12 run: diff --git a/cmd/manager/main.go b/cmd/manager/main.go index a72205a..a58dd80 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -83,7 +83,7 @@ func RefreshWatchers(ctx context.Context, kubeClient client.Reader) error { watchers = []v1alpha1.Watcher{} - for idx, watcher := range watcherList.Items { + for _, watcher := range watcherList.Items { for _, secretKeySelector := range watcher.Spec.ValuesFrom.Secrets { var ( secret v1.Secret @@ -101,7 +101,7 @@ func RefreshWatchers(ctx context.Context, kubeClient client.Reader) error { return unmarshallErr } - if mergeErr := mergo.Merge(&watcherList.Items[idx], v1alpha1.Watcher{Spec: specFromSecret}, + if mergeErr := mergo.Merge(&watcher, v1alpha1.Watcher{Spec: specFromSecret}, mergo.WithOverride, mergo.WithAppendSlice); mergeErr != nil { return mergeErr }