[DRAFT] Switch helm deploy to util templating functions #9065
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.
Fixes: #9062
Related: #9063
Note This is a raw draft. I'm extremely aware that this PR does have no unit tests at all and does not contain any docs update. It is meant as a foundation to discuss an architecture how to achieve the stated goals. As soon as the direction is clear, unit tests + docs are absolutely necessary.
Description
The goal is to have consistent templating available for the helm renderer & deployer. This includes:
default
)Change overview
To achieve this, a
Templater
has been added topkg/skaffold/util/template.go
. The intention is to have something to instantiate once which carries along all configuration and a base set of template-able values. After that, a number of templates can be rendered with optional overrides.Helm specific templating logic can be found in
pkg/skaffold/helm/template.go
. The goal here is to have one location containing templating logic. This should avoid different stages 'drifting' away from each other (e.g. helm deploy vs. helm render).All other changes are in
pkg/skaffold/helm/*.go
to centralize templater instantiation, passing it around and using the new rendering functions.Known Implementation Drawbacks
Templater.Render
. Always looping over all the available values seems wasteful, I just don't know how to solve this best.Known Architecture Drawbacks
User facing changes
New features
Users are now able to use every std and sprig template function in every field consistently.
Additionally, which fields are available for templating has been unified to have them all available in every already template-able field.
UX Changes
Previously, templating was done on demand. This means, during a deploy, release of helm chart A might be deployed, but during release of helm chart B templating failed, making the whole deploy fail in the middle.
Templating of every chart has been moved in front deploying. This means in contrast to before, templating has to succeed for all releases before any deploy is attempted. IMHO this is a better solution than to fail in the middle.
Follow-up Work
Many other parts of skaffold template, too. With the code in this PR, templating logic is now split in
pkg/skaffold/util/env_tempalte.go
andpkg/skaffold/util/template.go
in an effort to start with one part but be able to continue switching other templating to the new structure, too.IMHO regardless of renderer/deployer/tagger, templating should work consistently inside skaffold. To achieve this, having one central piece of templating logic might be a solution to be discussed.