feat(template): support repeatable --fqdn-template, --target-template, --fqdn-target-template flags#6429
Conversation
…arget-template flags Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…arget-template flags Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Coverage Report for CI Build 25665899121Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-0.01%) to 80.572%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions49 previously-covered lines in 4 files lost coverage.
Coverage Stats
💛 - Coveralls |
vflaux
left a comment
There was a problem hiding this comment.
One caveat concerns the use of variables or define blocks in templates. Because flags are concatenated into a single, unified template, these variables are shared across all flags. This can lead to unexpected behavior for users.
This should at least be clearly documented.
|
Could you clarify those unexpected behaviours? I might missing them |
There was a problem hiding this comment.
Variable should actually not cause issues as you can redefine them, but define block will :
{{ define "foo" }}bar{{ end }}{{ template "foo" }}{{ define "foo" }}foobar{{ end }}{{ template "foo" }}
Should results in multiple definition of template "foo".
Also any invalid template will make other templates invalid too.
I'm missing the point here, why we care about edge cases, there are way too many things that could go wrong, user input is responsibility of the user, unless we could automate checks? How supporting multiple templates flags relates to all of this? Currently user could define multiple templates in single line, this is just to allow to define them in multiple flags. Template engine is supported for a while, we are using golang template engine. If the user define incorrect template, or missplace variable (could not be compiled or whatever) high chances the external-dns template engine will catch that and it will fail fast Line 131 in 26b72c1 There are two states resulting template either parsed successfully or not. Could you specify what need to be added and where, I could copy paste it then. |
…arget-template flags Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…arget-template flags Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
|
I've removed sort for flags, to make order clear and added logging for resulting templates. The right location for logging is execute.go but it is hard to test it there |
…, --fqdn-target-template flags Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
|
I've added validation and debug logging to make things clear in case of config misconfiguration. |
…, --fqdn-target-template flags Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…, --fqdn-target-template flags Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…, --fqdn-target-template flags Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: u-kai The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Since logs are now emitted, I can't claim there are zero edge cases, but the pre-fix behavior was already broken (specifying --fqdn-target-template multiple times silently discarded all but the last value). IMO, given that, this fix is the right call. |
What does it do ?
Motivation
More