You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem 1: Helm doesn't short circuit and conditions
Creating a helm chart with kubebuilder edit --plugins=helm/v1-alpha creates a ServiceAccount template:
{{- if .Values.rbac.enable }}apiVersion: v1kind: ServiceAccountmetadata:
labels:
{{- include "chart.labels" . | nindent 4 }}{{- if and .Values.controllerManager.serviceAccount .Values.controllerManager.serviceAccount.annotations }}annotations:
{{- range $key, $value := .Values.controllerManager.serviceAccount.annotations }}{{ $key }}: {{ $value }}{{- end }}{{- end }}name: {{ .Values.controllerManager.serviceAccountName }}namespace: {{ .Release.Namespace }}{{- end -}}
The issue is the following line of code:
{{- if and .Values.controllerManager.serviceAccount .Values.controllerManager.serviceAccount.annotations }}
This does not work because Values.controllerManager.serviceAccount is not set by default and Helm evaluates all statements in the and condition first. I.e. the following error arises:
{{- if and .Values.controllerManager.pod .Values.controllerManager.pod.labels }}
{{- range $key, $value := .Values.controllerManager.pod.labels }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
Proposed solution:
In both cases we can just use a with statement so that the subkey is not checked if the parent doesn't exist e.g.:
{{- with .Values.controllerManager.pod }}{{- if .labels }}{{- range $key, $value := .labels }}{{ $key }}: {{ $value }}{{- end }}{{- end }}{{- end }}
Problem 2: webhook not set by default in values.yaml
The webhook key is not set by default in the values.yaml. However, in multiple places webhook.enabled is checked.
Proposed solution:
An easy consistent solution would be to just set the following in the values.yaml.
webhook:
enable: false
If I make the above changes Helm can template the chart.
I'm happy to fix this if the proposed solutions are accepted.
Reproducing this issue
No response
KubeBuilder (CLI) Version
4.5.0
PROJECT version
No response
Plugin versions
Other versions
No response
Extra Labels
No response
The text was updated successfully, but these errors were encountered:
What broke? What's expected?
Problem 1: Helm doesn't short circuit
and
conditionsCreating a helm chart with
kubebuilder edit --plugins=helm/v1-alpha
creates a ServiceAccount template:The issue is the following line of code:
This does not work because Values.controllerManager.serviceAccount is not set by default and Helm evaluates all statements in the and condition first. I.e. the following error arises:
Same problem exists for pod.labels:
Proposed solution:
In both cases we can just use a with statement so that the subkey is not checked if the parent doesn't exist e.g.:
Problem 2: webhook not set by default in values.yaml
The webhook key is not set by default in the values.yaml. However, in multiple places webhook.enabled is checked.
Proposed solution:
An easy consistent solution would be to just set the following in the values.yaml.
If I make the above changes Helm can template the chart.
I'm happy to fix this if the proposed solutions are accepted.
Reproducing this issue
No response
KubeBuilder (CLI) Version
4.5.0
PROJECT version
No response
Plugin versions
Other versions
No response
Extra Labels
No response
The text was updated successfully, but these errors were encountered: