fix(ingress): accept pre-CIDR externalIPs in CiliumLoadBalancerIPPool

Address review feedback from gemini-code-assist on
packages/extra/ingress/templates/cilium-lb-pool.yaml:19: if the operator
passes an externalIP already in CIDR form (192.0.2.10/32 or 2001:db8::1/128),
the template appended a second /32 or /128 suffix producing an invalid
CiliumLoadBalancerIPPool block. Guard the suffix append on the absence of
"/" in the input.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
Aleksei Sviridkin 2026-04-23 23:24:38 +03:00
parent adc7abe5c1
commit 6af74cec0e
No known key found for this signature in database
GPG key ID: 7988329FDF395282
2 changed files with 15 additions and 1 deletions

View file

@ -16,7 +16,7 @@ metadata:
spec:
blocks:
{{- range $exposeIPsList }}
- cidr: {{ . }}/{{ if contains ":" . }}128{{ else }}32{{ end }}
- cidr: {{ . }}{{ if not (contains "/" .) }}/{{ if contains ":" . }}128{{ else }}32{{ end }}{{ end }}
{{- end }}
serviceSelector:
matchLabels:

View file

@ -249,3 +249,17 @@ tests:
path: spec.values.ingress-nginx.controller.service.externalIPs
value:
- 192.0.2.10
- it: loadBalancer mode accepts pre-CIDR input without double-suffixing
set:
_cluster:
expose-ingress: tenant-root
expose-external-ips: "192.0.2.10/32,2001:db8::1/128"
expose-mode: loadBalancer
asserts:
- template: templates/cilium-lb-pool.yaml
equal:
path: spec.blocks
value:
- cidr: 192.0.2.10/32
- cidr: 2001:db8::1/128