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

Keep indentation of arrays during update #1216

Closed
felipecrs opened this issue May 17, 2022 · 3 comments
Closed

Keep indentation of arrays during update #1216

felipecrs opened this issue May 17, 2022 · 3 comments

Comments

@felipecrs
Copy link

Please describe your feature request.

Sorry, I searched but I did not find any similar issue.

Consider a YAML file like:

apiVersion: v2
appVersion: "0.1.0"
description: A Helm chart
name: mychart
version: "0.1.0"
dependencies:
- name: anotherchart
  version: ">0.0.0-0"

And what happens is:

$ yq '(.dependencies[] | select(.name == "anotherchart") | .version) |= "1.1.1"' Chart.yaml
apiVersion: v2
appVersion: "0.1.0"
description: A Helm chart
name: mychart
version: "0.1.0"
dependencies:
  - name: anotherchart
    version: "1.1.1"
- - name: anotherchart
-   version: ">0.0.0-0"
+   - name: anotherchart
+     version: "1.1.1"

Describe the solution you'd like

I want the output to retain the original indentation of the array, i.e.:

apiVersion: v2
appVersion: "0.1.0"
description: A Helm chart
name: mychart
version: "0.1.0"
dependencies:
- name: anotherchart
  version: "1.1.1"

Describe alternatives you've considered
I haven't found any way around it.

Additional context
N/A

@mikefarah
Copy link
Owner

Yep this is a known and documented issue with the underlying go-yaml parser :(

#465, #462

@felipecrs
Copy link
Author

Thank you!

@JannemanDev
Copy link

This is quite a dealbreaker when using version control where fill diffs are important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants