Skip to content

Commit 2fce204

Browse files
authored
fix: ensure boolean flags are only passed when their corresponding Helm chart value is true (#467)
Issue: aws-controllers-k8s/community#1893 In this commit, we address the issue of passing boolean flags in a more solid way. We've observed an odd obehaviour when a user attempts to disabled a feature (e.g `leaderElection/developmentLogging`), which causes the flag to be enabled instead. The main root cause of this issue was, using environment vairables with the `pflag` library, combined with the fact that `spf13/cobra` library conciders passed boolean flags with no values (no `=<value>`) as `true` The fix consists of 1. Avoid using environment variables for boolean flags. 2. Updating the helm template to only pass boolean flags when their respctive helm chat values are present. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent a2e3c2e commit 2fce204

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

templates/helm/templates/deployment.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ spec:
4848
- "$(AWS_REGION)"
4949
- --aws-endpoint-url
5050
- "$(AWS_ENDPOINT_URL)"
51+
{{- if .Values.log.enable_development_logging }}
5152
- --enable-development-logging
52-
- "$(ENABLE_DEVELOPMENT_LOGGING)"
53+
{{- end }}
5354
- --log-level
5455
- "$(ACK_LOG_LEVEL)"
5556
- --resource-tags
@@ -58,10 +59,11 @@ spec:
5859
- "$(ACK_WATCH_NAMESPACE)"
5960
- --deletion-policy
6061
- "$(DELETION_POLICY)"
62+
{{- if .Values.leaderElection.enabled }}
6163
- --enable-leader-election
62-
- "$(ENABLE_LEADER_ELECTION)"
6364
- --leader-election-namespace
6465
- "$(LEADER_ELECTION_NAMESPACE)"
66+
{{- end }}
6567
{{- if gt .Values.reconcile.defaultResyncPeriod 0.0 }}
6668
- --reconcile-default-resync-seconds
6769
- "$(RECONCILE_DEFAULT_RESYNC_SECONDS)"
@@ -91,12 +93,8 @@ spec:
9193
value: {{ include "watch-namespace" . }}
9294
- name: DELETION_POLICY
9395
value: {{ .Values.deletionPolicy }}
94-
- name: ENABLE_LEADER_ELECTION
95-
value: {{ .Values.leaderElection.enabled | quote }}
9696
- name: LEADER_ELECTION_NAMESPACE
9797
value: {{ .Values.leaderElection.namespace | quote }}
98-
- name: ACK_ENABLE_DEVELOPMENT_LOGGING
99-
value: {{ .Values.log.enable_development_logging | quote }}
10098
- name: ACK_LOG_LEVEL
10199
value: {{ .Values.log.level | quote }}
102100
- name: ACK_RESOURCE_TAGS

0 commit comments

Comments
 (0)