Repository navigation
feat: support merging www and apex routes if defined separately - #530
Draft
shreddedbacon wants to merge 1 commit into
Draft
shreddedbacon wants to merge 1 commit into
shreddedbacon wants to merge 1 commit into
Conversation
shreddedbacon
force-pushed
the
merge-route-to-apex
branch
from
September 21, 2026 00:51
d0ae305 to
70455f2
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Merging can discard route configuration and change an explicitly selected primary hostname.
2 open issues
What changed in this PR
This PR adds opt-in consolidation of separately defined apex and www routes into a single ingress, reducing ingress and certificate counts.
Changes:
- Adds the
ROUTE_MERGE_APEXfeature flag and integrates merging into route generation. - Adds merge eligibility checks and preserves the first-listed hostname.
- Adds unit tests, command-level tests, and expected ingress fixtures.
| File | Description |
|---|---|
| internal/testdata/node/lagoon.yml | Adds route pairs and alternative-name fixtures. |
| internal/testdata/node/ingress-templates/multidomain-merge-apex-routes/www.example4.com.yaml | Expected www ingress with existing aliases. |
| internal/testdata/node/ingress-templates/multidomain-merge-apex-routes/www.example3.com.yaml | Expected merged ingress with www listed first. |
| internal/testdata/node/ingress-templates/multidomain-merge-apex-routes/example2.com.yaml | Expected apex ingress with existing aliases. |
| internal/testdata/node/ingress-templates/multidomain-merge-apex-routes/example.com.yaml | Expected merged apex ingress with monitoring. |
| internal/lagoon/routes.go | Implements route pairing and merge eligibility checks. |
| internal/lagoon/routes_test.go | Tests merging, ordering, and selected exclusions. |
| internal/generator/ingress.go | Applies merging when enabled. |
| internal/generator/generator.go | Reads the merge feature flag. |
| internal/generator/buildvalues.go | Stores the merge setting. |
| cmd/template_ingress_test.go | Adds merged-ingress rendering coverage. |
| cmd/identify_ingress_test.go | Adds route-identification coverage with merging enabled. |
Review effort: Balanced
Comment on lines
+528
to
+537
| if !canMergeWWWRoute(routes[apexIdx], routes[wwwIdx]) { | ||
| continue | ||
| } | ||
|
|
||
| // whichever domain appears earliest in the original list is retained as-is; | ||
| // the later one is folded into it as an alternativeName | ||
| keepIdx, dropIdx := apexIdx, wwwIdx | ||
| if wwwIdx < apexIdx { | ||
| keepIdx, dropIdx = wwwIdx, apexIdx | ||
| } |
Comment on lines
+539
to
+540
| routes[keepIdx].AlternativeNames = helpers.AppendIfMissing(routes[keepIdx].AlternativeNames, routes[dropIdx].Domain) | ||
| folded[routes[dropIdx].Domain] = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds support for consolidating www and apex domains into one ingress object to reduce certificate and ingress object counts in a cluster.