Skip to content

refactor(fqdn): encapsulate FQDN template logic into TemplateEngine - #6292

Merged
k8s-ci-robot merged 29 commits into
kubernetes-sigs:masterfrom
gofogo:chore-fqdn-source-extract
Mar 23, 2026
Merged

refactor(fqdn): encapsulate FQDN template logic into TemplateEngine#6292
k8s-ci-robot merged 29 commits into
kubernetes-sigs:masterfrom
gofogo:chore-fqdn-source-extract

Conversation

@ivankatliarchuk

@ivankatliarchuk ivankatliarchuk commented Mar 17, 2026

Copy link
Copy Markdown
Member

What does it do ?

  • Introduced fqdn.TemplateEngine (value type) encapsulating templates and the combineFQDN flag
  • Replaced the free function CombineWithTemplatedEndpoints with TemplateEngine.CombineWithEndpoints method
  • Made routeGroup implement kubeObject (embed metav1.TypeMeta/ObjectMeta), eliminating the deprecated ExecuteFQDN path
  • Extracted template helper functions into fqdn/functions.go with their own tests

Follow-up

Motivation

One place to change. Adding a fourth template field, changing combine semantics, adding a new template function - all changes land in fqdn/ and propagate automatically to all 10+ sources.

FQDN template handling was duplicated inline across ~10 source files — each called a free function with inconsistent guarding and accessed the engine's internals directly. There was no single place to reason about template configuration or behavior.

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@k8s-ci-robot
k8s-ci-robot requested review from szuecs and vflaux March 17, 2026 22:19
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 17, 2026
@coveralls

coveralls commented Mar 17, 2026

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23435131007

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 332 unchanged lines in 15 files lost coverage.
  • Overall coverage increased (+0.2%) to 78.224%

Files with Coverage Reduction New Missed Lines %
fake.go 1 96.08%
integration/toolkit/toolkit.go 2 0.0%
pod.go 5 97.18%
node.go 12 90.48%
istio_gateway.go 16 89.88%
execute.go 19 76.3%
openshift_route.go 19 83.74%
contour_httpproxy.go 20 83.72%
ingress.go 21 88.42%
store.go 28 63.87%
Totals Coverage Status
Change from base Build 23401388822: 0.2%
Covered Lines: 16409
Relevant Lines: 20977

💛 - Coveralls

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@k8s-ci-robot k8s-ci-robot added the controller Issues or PRs related to the controller label Mar 17, 2026
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk ivankatliarchuk changed the title refactor(source): extract FQDN template logic into fqdn.TemplateEngine refactor(fqdn): extract FQDN template logic into fqdn.TemplateEngine Mar 18, 2026
@ivankatliarchuk
ivankatliarchuk marked this pull request as draft March 18, 2026 07:52
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 18, 2026
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk
ivankatliarchuk marked this pull request as ready for review March 18, 2026 08:01
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 18, 2026
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk ivankatliarchuk changed the title refactor(fqdn): extract FQDN template logic into fqdn.TemplateEngine refactor(fqdn): encapsulate FQDN template logic into fqdn.TemplateEngine Mar 18, 2026
@ivankatliarchuk ivankatliarchuk changed the title refactor(fqdn): encapsulate FQDN template logic into fqdn.TemplateEngine refactor(fqdn): encapsulate FQDN template logic into TemplateEngine Mar 18, 2026
ivankatliarchuk and others added 4 commits March 21, 2026 15:13
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Comment thread source/contour_httpproxy.go Outdated
annotationFilter string
fqdnTemplate *template.Template
combineFQDNAnnotation bool
templates fqdn.TemplateEngine

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using templates can make you think it's an array of fqdn.Template.
Since it's a fqdn.TemplateEngine, shouldn't the variable be named templateEngine ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging. Changed everywhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk

ivankatliarchuk commented Mar 23, 2026

Copy link
Copy Markdown
Member Author

I renamed fqdn package to templateenginge

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Comment thread source/wrappers/build_test.go
Comment thread source/templateegine/engine.go Outdated
limitations under the License.
*/

package templateegine

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
package templateegine
package template

There is a typo in the directory name & package name.
It should be at least templateengine.
Since the type is now named Engine, the package could be named template so it would be called in all sources with template.Engine.
Wdyt ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Make sense

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk

ivankatliarchuk commented Mar 23, 2026

Copy link
Copy Markdown
Member Author

moved template engine test utils under source/template/testutil/testutil.go. Source tests no need to be aware of template engine creation cbf39cf

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>

@mloiseleur mloiseleur left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very clear now 👍.
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 23, 2026
@ivankatliarchuk

Copy link
Copy Markdown
Member Author

/approve

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ivankatliarchuk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 23, 2026
@k8s-ci-robot
k8s-ci-robot merged commit d217706 into kubernetes-sigs:master Mar 23, 2026
18 checks passed
@ivankatliarchuk
ivankatliarchuk deleted the chore-fqdn-source-extract branch March 23, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. controller Issues or PRs related to the controller lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants