-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support default values in all templateable helm fields #9062
Comments
Hi @girstenbrei the default function issue should be fixed in #8872, the release includes that change should happen soon. More importantly, Skaffold will be supporting all templates from sprig thanks brian for making the change #9005 |
oh sorry .. i misunderstood the problem, thought all places are using missingkey=invalid now, it turns out that only tagging phase uses missingkey=invalid strategy. We need to use the same method for templateExpanding. |
I'd also like to see templating used everywhere for starters, then adding the I took a look at adding templating everywhere prior to creating an issue for it, but was unable to see a clear path to doing so. My strategy may have been a dead end. It wasn't about parsing and executing the templates (although that should happen in a single pass and the parses should be cached for execution speed), it's about managing the dynamic context and executing the template when it is used. The templates simply cannot be executed earlier than they are used because they will by nature depend on values generated elsewhere in the lifecycle(s). @ericzzzzzzz, is there some place that the original static (configuration) context as well as current dynamic context can be accessed in a read-only manner? |
@ericzzzzzzz Thanks for the hint, I missed #8872 . The solution should be somewhat similar to it, I guess. As you already created #9063 , I would defer the discussion which fields to template and what information is available to template with. For this issue, I'd like to focus on changing how templating evaluates to allow using the |
Using the helm deployer, some fields are available for templating.
These include
deploy.helm.releases[].name
anddeploy.helm.releases[].setValueTemplates
. For some of those fields, it is necessary that if a value is set, the value is not empty (e.g. but not limited to thedeploy.helm.releases[].name
).This is currently achieved by util.ExpandEnvTemplateOrFail(...) which set's
missingkey=error
introduced for #5072 .While I very much agree that failing fast for an accidentally empty value is important, this has the consequence that trying to use the default function like
{{ default "foo" .NAME }}
is also not possible if.NAME
is not defined, which in my opinion invalidates the usage of default.Expected behavior
Fields which support templating should IMHO support the same templating language and logic.
Actual behavior
Some fields support templating defaults, some don't.
Information
Steps to reproduce the behavior
skaffold deploy
orskaffold render
both fail with:Proposed solution
For fields in helm currently using
util.ExpandEnvTemplateOrFail(...)
, switch to the existingutil.ExpandEnvTemplate(...)
(which does not error on a missing key) and handle an empty string returned as an error after templating. It may be a good idea to centralize the templating of those fields intopkg/skaffold/helm/util.go
to ensure consistent behaviour between render and deploy, but I don't know the codebase well, so I'm very open to suggestions here.If this is a viable Path forward, I'd be interested in starting a PR. Feel free to let me know any other feedback as well.
Greets,
Christoph
The text was updated successfully, but these errors were encountered: