|
{{- if and .Values.reloader.watchGlobally .Values.reloader.namespaceSelector -}} |
Bug Report: Helm Chart Helper Template Logic Error in reloader-namespaceSelector
Chart Version: 2.2.14
App Version: v1.4.19
Summary
The reloader-namespaceSelector helper template in templates/_helpers.tpl has contradictory logic between its comment and implementation, causing the --namespace-selector CLI flag to never be generated when watchGlobally: false.
Issue
File: templates/_helpers.tpl
Current Code:
{{/*
Create the namespace selector if it does not watch globally
*/}}
{{- define "reloader-namespaceSelector" -}}
{{- if and .Values.reloader.watchGlobally .Values.reloader.namespaceSelector -}}
{{ .Values.reloader.namespaceSelector }}
{{- end -}}
{{- end -}}
Problem:
- The comment states the function creates the namespace selector "if it does not watch globally"
- The code implements the opposite: it requires
watchGlobally: true
- When
watchGlobally: false and namespaceSelector is set, the CLI flag is not generated
- When
watchGlobally: true and namespaceSelector is set, the flag is correctly generated
Expected Behavior
One of the following should be true:
Option A (Restrict Mode):
if and (not .Values.reloader.watchGlobally) .Values.reloader.namespaceSelector
- When
watchGlobally: false, use namespaceSelector to limit to specific namespaces (restrictive by default)
Option B (Filter Mode):
- Keep current implementation but fix the comment:
{{/*
Create the namespace selector when watching globally to filter namespaces
*/}}
Impact
Users cannot deploy Reloader with watchGlobally: false and namespace selectors as documented in values.yaml comments. The documented use case of "Comma separated list of k8s label selectors for namespaces selection" only works when watchGlobally: true, which contradicts intuitive user expectations.
Reproduction
# values-test.yaml
reloader:
watchGlobally: false
namespaceSelector: "app=myapp"
deployment:
replicas: 1
helm template reloader stakater/reloader --values values-test.yaml
# Expected: args contain "--namespace-selector="app=myapp""
# Actual: args do NOT contain the flag (empty)
Suggested Fix
Clarify intended behavior:
- Update comment to match code behavior, OR
- Update code to match comment:
if and (not .Values.reloader.watchGlobally) .Values.reloader.namespaceSelector
The logical intent (based on parameter naming) suggests Option A is more correct: namespaceSelector should restrict scope when not watching globally.
Reloader/deployments/kubernetes/chart/reloader/templates/_helpers.tpl
Line 86 in dd72380
Bug Report: Helm Chart Helper Template Logic Error in reloader-namespaceSelector
Chart Version: 2.2.14
App Version: v1.4.19
Summary
The
reloader-namespaceSelectorhelper template intemplates/_helpers.tplhas contradictory logic between its comment and implementation, causing the--namespace-selectorCLI flag to never be generated whenwatchGlobally: false.Issue
File:
templates/_helpers.tplCurrent Code:
{{/* Create the namespace selector if it does not watch globally */}} {{- define "reloader-namespaceSelector" -}} {{- if and .Values.reloader.watchGlobally .Values.reloader.namespaceSelector -}} {{ .Values.reloader.namespaceSelector }} {{- end -}} {{- end -}}Problem:
watchGlobally: truewatchGlobally: falseandnamespaceSelectoris set, the CLI flag is not generatedwatchGlobally: trueandnamespaceSelectoris set, the flag is correctly generatedExpected Behavior
One of the following should be true:
Option A (Restrict Mode):
watchGlobally: false, usenamespaceSelectorto limit to specific namespaces (restrictive by default)Option B (Filter Mode):
Impact
Users cannot deploy Reloader with
watchGlobally: falseand namespace selectors as documented in values.yaml comments. The documented use case of "Comma separated list of k8s label selectors for namespaces selection" only works whenwatchGlobally: true, which contradicts intuitive user expectations.Reproduction
Suggested Fix
Clarify intended behavior:
if and (not .Values.reloader.watchGlobally) .Values.reloader.namespaceSelectorThe logical intent (based on parameter naming) suggests Option A is more correct:
namespaceSelectorshould restrict scope when not watching globally.