Skip to content

Commit 06f836d

Browse files
Fix helm template for empty validator env lists
The clusterpolicy.yaml template was rendering invalid YAML when validator's env fields were empty lists. The template would render parent keys (`plugin:`) without any child fields, which is not a valid YAML. This commit explicity renders `env: []` when it is empty, making the default CR valid. Signed-off-by: Rajath Agasthya <[email protected]>
1 parent ee9210b commit 06f836d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

deployments/gpu-operator/templates/clusterpolicy.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,42 +89,56 @@ spec:
8989
plugin:
9090
{{- if .Values.validator.plugin.env }}
9191
env: {{ toYaml .Values.validator.plugin.env | nindent 8 }}
92+
{{- else }}
93+
env: []
9294
{{- end }}
9395
{{- end }}
9496
{{- if .Values.validator.cuda }}
9597
cuda:
9698
{{- if .Values.validator.cuda.env }}
9799
env: {{ toYaml .Values.validator.cuda.env | nindent 8 }}
100+
{{- else }}
101+
env: []
98102
{{- end }}
99103
{{- end }}
100104
{{- if .Values.validator.driver }}
101105
driver:
102106
{{- if .Values.validator.driver.env }}
103107
env: {{ toYaml .Values.validator.driver.env | nindent 8 }}
108+
{{- else }}
109+
env: []
104110
{{- end }}
105111
{{- end }}
106112
{{- if .Values.validator.toolkit }}
107113
toolkit:
108114
{{- if .Values.validator.toolkit.env }}
109115
env: {{ toYaml .Values.validator.toolkit.env | nindent 8 }}
116+
{{- else }}
117+
env: []
110118
{{- end }}
111119
{{- end }}
112120
{{- if .Values.validator.vfioPCI }}
113121
vfioPCI:
114122
{{- if .Values.validator.vfioPCI.env }}
115123
env: {{ toYaml .Values.validator.vfioPCI.env | nindent 8 }}
124+
{{- else }}
125+
env: []
116126
{{- end }}
117127
{{- end }}
118128
{{- if .Values.validator.vgpuManager }}
119129
vgpuManager:
120130
{{- if .Values.validator.vgpuManager.env }}
121131
env: {{ toYaml .Values.validator.vgpuManager.env | nindent 8 }}
132+
{{- else }}
133+
env: []
122134
{{- end }}
123135
{{- end }}
124136
{{- if .Values.validator.vgpuDevices }}
125137
vgpuDevices:
126138
{{- if .Values.validator.vgpuDevices.env }}
127139
env: {{ toYaml .Values.validator.vgpuDevices.env | nindent 8 }}
140+
{{- else }}
141+
env: []
128142
{{- end }}
129143
{{- end }}
130144

0 commit comments

Comments
 (0)