Skip to content

Commit 04e30f0

Browse files
DrFaust92claude
andcommitted
fix(helm): harden dnsConfig helper per review
Address CodeRabbit feedback on the dnsConfig helper: - When dnsPolicy is "None", Kubernetes requires at least one nameserver (searches/options alone are rejected by the API server). Tighten the guard to require .nameservers specifically instead of any config field. - Tolerate a null/missing dnsConfig object (`and . .enabled`) and default .policy to "ClusterFirst" when unset, so the template never panics or emits an empty `dnsPolicy: ""`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent dd2c56b commit 04e30f0

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎helm/robusta/templates/_helpers.tpl‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ Pass the component's dnsConfig dict as the context, e.g.:
1818
When disabled (or unset) it falls back to dnsPolicy: ClusterFirst.
1919
*/}}
2020
{{- define "robusta.dnsConfig" -}}
21-
{{- if .enabled -}}
21+
{{- if and . .enabled -}}
22+
{{- $policy := default "ClusterFirst" .policy -}}
2223
{{- $hasConfig := or .nameservers .searches .options -}}
23-
{{- if and (eq .policy "None") (not $hasConfig) -}}
24-
{{- fail "dnsConfig: when dnsPolicy is 'None', you must set at least one of nameservers, searches, or options" -}}
24+
{{- if and (eq $policy "None") (not .nameservers) -}}
25+
{{- fail "dnsConfig: when dnsPolicy is 'None', you must provide at least one nameserver (Kubernetes requires it)" -}}
2526
{{- end -}}
26-
dnsPolicy: {{ .policy | quote }}
27+
dnsPolicy: {{ $policy | quote }}
2728
{{- if $hasConfig }}
2829
dnsConfig:
2930
{{- with .nameservers }}

0 commit comments

Comments
 (0)