Skip to content

Commit 93d0317

Browse files
committed
fix(helm): reject false metrics port
Preserve explicitly configured metrics port values during validation so boolean false cannot be converted into the disabled numeric value. Signed-off-by: Andrey Maltsev <[email protected]>
1 parent af822ab commit 93d0317

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎deploy/helm/openshell/templates/_helpers.tpl‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ Validate chart values that Helm would otherwise accept silently.
276276
{{- end -}}
277277
{{- $servicePortValue := toString .Values.service.port -}}
278278
{{- $healthPortValue := toString .Values.service.healthPort -}}
279-
{{- $metricsPortValue := toString (default 0 .Values.service.metricsPort) -}}
279+
{{- $metricsPortValue := "0" -}}
280+
{{- if hasKey .Values.service "metricsPort" -}}
281+
{{- $metricsPortValue = toString (get .Values.service "metricsPort") -}}
282+
{{- end -}}
280283
{{- if not (regexMatch `^-?[0-9]+$` $servicePortValue) -}}
281284
{{- fail "service.port must be an integer." -}}
282285
{{- end -}}

‎deploy/helm/openshell/tests/gateway_ports_test.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ tests:
9595
- failedTemplate:
9696
errorPattern: "service.metricsPort must be an integer"
9797

98+
- it: rejects false instead of treating it as a disabled metrics port
99+
template: templates/statefulset.yaml
100+
set:
101+
service.metricsPort: false
102+
asserts:
103+
- failedTemplate:
104+
errorPattern: "service.metricsPort must be an integer"
105+
98106
- it: rejects a fractional metrics port
99107
template: templates/statefulset.yaml
100108
set:

0 commit comments

Comments
 (0)