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
.Release.Labels
are not available within values templates
#435
Comments
@sisrael-dn I will work on this. |
see: #394, we upgrade the yaml library into v3. it allows key overrides. @mumoshu what do you think? this should be an incompatible change, should we keep the new behavior, or fall back to v2? |
repositories:
- name: jenkinsci
url: https://charts.jenkins.io
templates:
jenkins: &jenkins
name: jenkins{{`{{.Release.Labels.jenkinsInstance}}`}}
chart: jenkinsci/jenkins
version: 4.1.16
labels:
group: jenkins
privateRegistry: 123456789.dkr.ecr.us-west-1.amazonaws.com
namespace: jenkins{{`{{.Release.Labels.jenkinsInstance}}`}}
values:
- jenkins.yaml.gotmpl
releases:
- labels:
group: jenkins
privateRegistry: 123456789.dkr.ecr.us-west-1.amazonaws.com
jenkinsInstance: "1"
zone: us-west-1b
branch: master
jobsTags: ""
<<: *jenkins |
@sisrael-dn upgrade your helmfile.yaml as shown above. It will be work correctly. |
https://yaml-online-parser.appspot.com/ we can test YAML on it. it will do the same thing as YAML v3. |
@sisrael-dn ping |
@mumoshu WDYT about this issue? Thanks very much. |
@sisrael-dn @yxxhero If we were to allow |
Our error is in the values render, not in the template render, that works fine. |
@yxxhero thank you for your explanation & suggestion, I have tested it and it seems to work with latest helmfile. |
This may be an incompatible change, but it conforms to the yaml specification. @sisrael-dn |
@tdaniely-dn Thanks, gotcha. But it should be made available via this part of code helmfile/pkg/state/state_exec_tmpl.go Line 31 in f2be486
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
ping pong |
Same here, since 0.147.0, parent template is unable to get labels values which are specified in child template. templates:
exchange: &exchange
secrets:
- secrets/redis.yaml
- secrets/rabbitmq.yaml
- secrets/{{`{{ .Release.Labels.app }}`}}.yaml
- secrets/{{`{{ .Release.Labels.app }}`}}-{{`{{ .Release.Labels.exchange }}`}}.yaml
- secrets/{{`{{ .Release.Name }}`}}.yaml
valuesTemplate:
- ../common/values/{{`{{ .Release.Labels.app }}`}}.yaml.gotmpl
- ../common/values/{{`{{ .Release.Labels.app }}`}}-{{`{{ .Release.Labels.exchange }}`}}.yaml.gotmpl
- values/{{`{{ .Release.Labels.app }}`}}.yaml.gotmpl
- values/{{`{{ .Release.Labels.app }}`}}-{{`{{ .Release.Labels.exchange }}`}}.yaml.gotmpl
- values/{{`{{ .Release.Name }}`}}.yaml.gotmpl
private-exchange-svc: &private-exchange-svc
<<: *exchange
labels:
app: private-exchange-svc
releases:
- name: private-exchange-svc-test-0
<<: *private-exchange-svc
labels:
exchange: test
|
The whole idea of labels usage for us is a deep merge of labels keys&values between |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@VladStarr @voron Thanks a lot for clarifying! Let met first say that your use case alone looks totally valid to me. What's complicating the resolution here is that your use relied on a behavior of a specific yaml parser implementation(go-yaml v2) which does not conform to the yaml spec. We should keep backward compatibility. But is treating a bug like a spec to keep the existing behavior the right thing to do...? I'd be happy if we could still consider it a bug. Instead of reverting the parser to the prev version, can we add another feature to support your use case? What if we add a new field, With it, I'd assume @VladStarr's previous example could be written like this:
@VladStarr's example needs a deep merge on labels only once, so as the use of I presume @voron's example might look a bit more complex. Hey @voron, how many "labels" fields across the templates and the release needs to be deep merged in your configuration? For Vlad's it was two. If you need three or more, it it would look like this:
|
This is a successor to #596. We need a smooth migration path from `gopkg.in/yaml.v2`, and this pull request moves it forward with `goccy/go-yaml` instead of `gopkg.in/yaml.v3`. Merging this unblocks users stuck in Helmfile v0.146.x or earlier due to #435, so that they can upgrade to 0.147.x or greater without updating their helmfile configs. We previously tried to upgrade to `yaml.v3` (#394) in Helmfile v0.x, presuming it won't break anything. Apparently, it broke use-cases where you want to layer release's `values` field over three or more release templates and releases (#435). We then tried to bring back `yaml.v2` for Helmfile v0.x and keep `yaml.v3` for the upcoming Helmfile v1. However, it failed due to incompatibility in the Unmarshaller interface between `yaml.v2` and `yaml.v3` (#596). `goccy/go-yaml` is, from my observation, a well-maintained alternative to `yaml.v2`. One of its premises is that it enables us to swap the implementation from `gopkg.in/yaml.v2` to `goccy/go-yaml` just by replacing the import directive. It seems to use the same `Unmarshaller` interface as yaml.v2 too. Once this PR gets merged, I'd like to follow-up with adding a new build-time variable and an envvar to set the proper default for the yaml parser Helmfile uses and the ability to switch the parser at runtime. All in all, the next Helmfile release, v0.150.0 will get reverted to use `gopkg.in/yaml.v2` by default which resolves #435. New users who started using Helmfile since any of v0.148.0, v0.148.1, and v0.149.0 might be already relying on the new behavior, They might need to specify a new envvar to enable `goccy/go-yaml`. Signed-off-by: yxxhero <aiopsclub@163.com> Signed-off-by: yxxhero <aiopsclub@163.com> Co-authored-by: yxxhero <aiopsclub@163.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
* feat: `inherit` field for release template inheritance Ref #435 (comment) Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> * Fix wording Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> * Comment on releaseWithInheritedTemplate Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> * Update Release Template doc with the new `inherit` feature Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> * Fix a typo in code comment Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
@VladStarr @voron FYI, #606 has been merged. You can try building helmfile from our main branch to give |
Ref #435 Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Ref #435 Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
@mumoshu @voron Hello great to see you all here in active discussion 👍 I would though like to clarify if we really dump labels pass-through or not. It's really cool to see a new feature such as I'd like to know if it will be still possible to use .Release.Labels and other .Release data inside valuesTemplate files during rendering. Since my usage is slightly different and I start using a lot more templating to achieve D.R.Y. Here's some examples:
If it goes I'm afraid lots from the values "dryness" perspective goes missing too :( I mean I didn't clearly get, imo it's bad if we loose either:
How do you see a deep merge of an array which is basically an "order-matters" data? |
Hello, sorry for buzz. Didn't read carefully enough( So this is about
I.e. how the array (values array) is supposed to be merged/overwritten/concatenated in this case, so what is the resulting values array for |
@mumoshu we need more docs for |
This should fix #435 for Helmfile v0.x releases since the next v0.150.0. We introduce a new envvar to opt-in to the new YAML library, so that you can give it a shot before upgrading your Helmfile to v1. The same envvar can be used to opt-out of the new YAML library after you upgrade to Helmfile v1, giving you a more flexible migration story. Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Operating system
macOS Monterey Version 12.5
Helmfile Version
0.147.0
Helm Version
3.10.1
Bug description
Since 0.147.0 it seems like
.Release.Labels
are no longer available to use within values templates.Same example works fine with previous releases.
Example helmfile.yaml
helmfile.yaml:
jenkins.yaml.gotmpl:
Error message you've seen (if any)
in ./helmfile.yaml: failed to render values files "jenkins.yaml.gotmpl": failed to render [jenkins.yaml.gotmpl], because of template: stringTemplate:2:21: executing "stringTemplate" at <.Release.Labels.privateRegistry>: map has no entry for key "privateRegistry"
Steps to reproduce
helmfile -f ./helmfile.yaml -l name=jenkins1 template
Working Helmfile Version
0.146.0
Relevant discussion
No response
The text was updated successfully, but these errors were encountered: