fix: validate empty route parentRefs and omit empty hostnames - #2386
fix: validate empty route parentRefs and omit empty hostnames#2386somaz94 wants to merge 1 commit into
Conversation
|
Hi @somaz94 , the Thanks, |
e3f0b41 to
44591f4
Compare
|
Hi @MinerYang, thanks for the review! You're right that To clarify the use case: this started as a pure rendering bug (#2385). The chart ships I've reworked the PR to match your view:
Thanks! |
Fixes goharbor#2385 Signed-off-by: somaz <genius5711@gmail.com>
44591f4 to
67a2843
Compare
|
Hi @MinerYang — thanks, and I think we're actually in full agreement: this PR does not make The use case is the chart's own defaults (issue #2385): with
The fix keeps the Gateway API semantics you describe:
|
|
@MinerYang I see the To restate the scope: this isn't about making If the follow-up is about something else — more unit-test coverage, narrowing the scope to just the |
Problem
When
expose.type: routeis used with the chart's own default values (expose.route.parentRefs: []andexpose.route.hosts: []),helm templatefails with:toYamlon an empty list returns the flow literal[], andnindent 2put it at the same indentation as the parentparentRefs:/hostnames:key, so it parsed as a sibling node.expose.type: routewas broken out of the box, with a cryptic error and no user override required.Fixes #2385
Fix
parentRefsandhostnamesare treated differently, matching their roles in the Gateway API HTTPRoute spec:parentRefs— an HTTPRoute with noparentRefsattaches to no Gateway and cannot serve traffic, so it is effectively required in route mode. When it is empty the template nowfails with a clear message instead of emitting invalid YAML.hostnames— genuinely optional per the spec (omitting it matches all hostnames), so it is wrapped in a{{- with }}guard and omitted when the list is empty, rendered atnindent 4when present.Validation
helm template --set expose.type=route,expose.tls.enabled=false .now fails with a clearexpose.route.parentRefs must be set …message (previously a cryptic YAML parse error).parentRefsset andhostsempty,parentRefsrenders andhostnamesis omitted.helm unittest -f 'test/unittest/gateway-apis/*.yaml' .passes (updated the empty-defaults case to assert the clear failure; added the parentRefs-set/hosts-empty case).helm lint .passes.