Skip to content
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 for multiple yaml documents in stdin/file #10867

Closed
wants to merge 1 commit into from

Conversation

jkroepke
Copy link

@jkroepke jkroepke commented Apr 15, 2022

What this PR does / why we need it:

Fixes #10866

Special notes for your reviewer:

Tested stdin yaml:

---
a:
  b: c
  c: d
  e: f
---
e: value
a:
  b: f
  e:
  
test: >-
  hello
  ---
  world
---
a:
  c: 4

Before (main branch):

% cat values.yaml | ./bin/helm template --repo https://jkroepke.github.io/helm-charts/ values -f - 
---
# Source: values/templates/values.yaml
a:
  b: c
  c: d
  e: f

After (this PR):

% cat values.yaml | ./bin/helm template --repo https://jkroepke.github.io/helm-charts/ values -f - 
---
# Source: values/templates/values.yaml
a:
  b: f
  c: 4
  e: null
e: value
test: hello --- world

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 15, 2022
@jkroepke jkroepke force-pushed the multi-doc-values branch 2 times, most recently from 2a887c7 to 6f5a8c5 Compare April 15, 2022 15:51
@joejulian
Copy link
Contributor

Can I suggest a different approach to Unmarshalling multi-document yaml? What about using this example? https://go.dev/play/p/MZNwxdUzxPo

@joejulian
Copy link
Contributor

I've tried the method you're suggesting, in the past, and something caused it to break mid-file. I can't remember what it was though.

@jkroepke
Copy link
Author

What about using this example?

It uses a different golang yaml library (sigs.k8s.io/yaml vs goyaml "github.com/go-yaml/yaml") and uses the v1?. No idea, if this is wanted

Kubernetes uses the same separater ( https://github.com/kubernetes/kubernetes/blob/a750d8054a6cb3167f495829ce3e77ab0ccca48e/staging/src/k8s.io/apimachinery/pkg/util/yaml/decoder.go#L199). I got this from here: kubernetes-sigs/yaml#37 (comment)

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 16, 2022
@jkroepke
Copy link
Author

jkroepke commented Apr 16, 2022

Based on kubernetes-sigs/yaml#37 (comment), I push a new version here.

I coped some code from here:

decoder := yaml.NewYAMLOrJSONDecoder(strings.NewReader(renderedContent), 4096)

I extract the relevant merge code to a new function and add unit tests.

@jkroepke jkroepke force-pushed the multi-doc-values branch 3 times, most recently from dc3bc98 to ae9bf5c Compare April 16, 2022 15:13
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 16, 2022
@jkroepke jkroepke force-pushed the multi-doc-values branch 3 times, most recently from b478de6 to d10962c Compare April 16, 2022 15:56
Copy link
Contributor

@joejulian joejulian left a comment

Choose a reason for hiding this comment

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

This looks great, to me!

I am not a core maintainer, though. This will still need their approval.

@jkroepke
Copy link
Author

@thomastaylor312 @adamreese What did you think?

@jkroepke
Copy link
Author

@joejulian How can I help here? Looks stale here.

@joejulian
Copy link
Contributor

@jkroepke I've been wondering that, too. Maybe the helm mailing list or, if you can attend, the helm developer call?

@jkroepke
Copy link
Author

jkroepke commented May 3, 2022

@jkroepke
Copy link
Author

@mattfarina What did you think?

@yxxhero
Copy link
Member

yxxhero commented May 23, 2022

@jkroepke I think you shuld write a HIP for this.

@jkroepke
Copy link
Author

@yxxhero helm/community#253 - lets go.

@jkroepke
Copy link
Author

jkroepke commented Jun 9, 2022

Any news here @yxxhero ?

@jkroepke jkroepke requested a review from yxxhero July 10, 2022 08:11
@yxxhero
Copy link
Member

yxxhero commented Jul 10, 2022

@jkroepke I think the code is good.

Copy link
Member

@yxxhero yxxhero left a comment

Choose a reason for hiding this comment

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

/lgtm

@yxxhero
Copy link
Member

yxxhero commented Jul 10, 2022

@hickeyma @marckhouzam @scottrigby Can you have a review on this. Thanks very much.

@iverberk
Copy link

@hickeyma @marckhouzam @scottrigby If you have some time, can you please review and (if ok) merge this addition? It unlocks a nice workflow to pass secrets securely to Helm (no intermediate disk storage needed).

@iverberk
Copy link

Friendly reminder to review this PR. It's fine (but slightly disappointing) ff there is no time or urgency to review this PR but it would be nice to get some kind of an update.

@yxxhero yxxhero added this to the 3.10.0 milestone Jul 27, 2022
@yxxhero
Copy link
Member

yxxhero commented Jul 27, 2022

@iverberk I added this to this 3.10.0

@iverberk
Copy link

Wonderful @yxxhero! Thanks for the update and putting this on a milestone, looking forward to start using it.

Copy link
Contributor

@hickeyma hickeyma left a comment

Choose a reason for hiding this comment

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

@jkroepke There is feedback in the HIP (helm/community#253 (review)) from @bacongobbler. Do you mind addressing the comments?

@jkroepke
Copy link
Author

Hi @hickeyma,

I read the feedback and there are currently no plan to more forward on the HIP. This PR add 30 lines of code and remove 9 lines of code excluding code for tests. From my point of view, a HIP feels too over engineered for this kind of change. I'm not going to document the existing values merge logic in detail or discuss about security implications which are not in scope of the helm project.

At least, the HIP feedback does not criticism the current implementation draft. I'm not sure, if there is an alternative solution to implement this feature from user perspective.

From code perspective, there are 2 approvals from 2 triage maintainers. All questions are resolved on this PR expect the lastest one. Unit tests are included. I would really like to move forward on the PR here.

@hickeyma
Copy link
Contributor

@jkroepke If this feature requires a HIP then the HIP needs to be agreed upon before the feature code can be merged as the feature implementation needs to follow the design.

@bacongobbler reviewed the HIP and provided feedback and it is good practice to address these comments first.

@jkroepke
Copy link
Author

jkroepke commented Aug 12, 2022

I saw the comments, and in some points I do not agree with him. I hope someone else from the community has enough motivation for this process. It's a pain to go through the comments and wait 2 months again for the next feedback loop.

Can you explain, why a HIP is strictly need?

@iverberk
Copy link

iverberk commented Aug 13, 2022

I agree with @jkroepke that this process seems very heavy-handed for the proposed change. It's basically achieving parity with something that can already be done on the CLI (providing multiple values files). It's also reusing a lot of the existing code. Of course, it's your prerogative to mandate following the HIP process but I think no one will be motivated enough to follow through, especially with the long feedback cycles. Maybe that's also indicative that this is a 'niche' change that doesn't affect a lot of people. That being said, I think the use-case is very valid and that this should be part of core Helm.

@jkroepke I've decided to go ahead and just merge the values files myself before presenting them to Helm. I've taken the mergeMaps function and applied it to the values files that I have loaded, after that it's just a matter of marshalling to bytes and feeding it via stdin. Maybe you can take a similar approach to get what you want (secure passing of values via stdin). Thanks for your efforts on this so far.

@jkroepke
Copy link
Author

I'm also still confused, why other features does not require a HIP, while this feature does.

#10693

I may not see the logic behind this.

@joejulian
Copy link
Contributor

Just to be clear, triage folks are not code maintainers. We triage issues. Our feedback on PRs has exactly as much weight as anybody else in the community.

@hickeyma hickeyma modified the milestones: 3.10.0, 3.11.0 Sep 23, 2022
@mattfarina mattfarina modified the milestones: 3.11.0, 3.12.0 Jan 18, 2023
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review feature size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multiple YAML documents through stdin
7 participants