Skip to content

Commit 8f94e30

Browse files
refactor: case-insensitive normalization for resources-to-ignore
Use strings.ToLower so any casing (configMaps, ConfigMaps, sEcrets) normalizes to the canonical lowercase ResourceMap key, and simplify the flag help text. Addresses PR review feedback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c46937c commit 8f94e30

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

internal/pkg/util/util.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func ConfigureReloaderFlags(cmd *cobra.Command) {
9393
cmd.PersistentFlags().StringVar(&options.LogFormat, "log-format", "", "Log format to use (empty string for text, or JSON)")
9494
cmd.PersistentFlags().StringVar(&options.LogLevel, "log-level", "info", "Log level to use (trace, debug, info, warning, error, fatal and panic)")
9595
cmd.PersistentFlags().StringVar(&options.WebhookUrl, "webhook-url", "", "webhook to trigger instead of performing a reload")
96-
cmd.PersistentFlags().StringSliceVar(&options.ResourcesToIgnore, "resources-to-ignore", options.ResourcesToIgnore, "list of resources to ignore (valid options 'configmaps' or 'secrets'; 'configMaps' is also accepted for backward compatibility)")
96+
cmd.PersistentFlags().StringSliceVar(&options.ResourcesToIgnore, "resources-to-ignore", options.ResourcesToIgnore, "list of resources to ignore (valid options 'configmaps' or 'secrets')")
9797
cmd.PersistentFlags().StringSliceVar(&options.WorkloadTypesToIgnore, "ignored-workload-types", options.WorkloadTypesToIgnore, "list of workload types to ignore (valid options: 'jobs', 'cronjobs', or both)")
9898
cmd.PersistentFlags().StringSliceVar(&options.NamespacesToIgnore, "namespaces-to-ignore", options.NamespacesToIgnore, "list of namespaces to ignore")
9999
cmd.PersistentFlags().StringSliceVar(&options.NamespaceSelectors, "namespace-selector", options.NamespaceSelectors, "list of key:value labels to filter on for namespaces")
@@ -113,13 +113,13 @@ func GetIgnoredResourcesList() (List, error) {
113113

114114
ignoredResourcesList := options.ResourcesToIgnore // getStringSliceFromFlags(cmd, "resources-to-ignore")
115115

116-
// Normalize to the canonical lowercase keys used in kube.ResourceMap.
117-
// Accept the legacy "configMaps" spelling for backward compatibility with
118-
// charts that still emit the camelCase form.
116+
// Normalize to the canonical lowercase keys used in kube.ResourceMap so the
117+
// comparison is case-insensitive (e.g. "configMaps", "ConfigMaps", "sEcrets"
118+
// all map to their canonical lowercase form).
119119
normalized := make(List, 0, len(ignoredResourcesList))
120120
for _, v := range ignoredResourcesList {
121-
switch v {
122-
case "configMaps", "configmaps":
121+
switch strings.ToLower(v) {
122+
case "configmaps":
123123
normalized = append(normalized, "configmaps")
124124
case "secrets":
125125
normalized = append(normalized, "secrets")

internal/pkg/util/util_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,24 @@ func TestGetIgnoredResourcesList(t *testing.T) {
161161
expectError: false,
162162
expected: []string{"configmaps"},
163163
},
164+
{
165+
name: "Mixed-case ConfigMaps normalizes to configmaps",
166+
resources: []string{"ConfigMaps"},
167+
expectError: false,
168+
expected: []string{"configmaps"},
169+
},
164170
{
165171
name: "secrets",
166172
resources: []string{"secrets"},
167173
expectError: false,
168174
expected: []string{"secrets"},
169175
},
176+
{
177+
name: "Mixed-case sEcrets normalizes to secrets",
178+
resources: []string{"sEcrets"},
179+
expectError: false,
180+
expected: []string{"secrets"},
181+
},
170182
{
171183
name: "Empty list",
172184
resources: []string{},

0 commit comments

Comments
 (0)