We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug As described in https://mikefarah.gitbook.io/yq/operators/assign-update#update-empty-object-and-array, updating a file with an existing empty map results in a one-liner yaml. In our use case, this makes helm template to break.
Version of yq: 4.24.2 Operating system: tested on mac and linux Installed via: homebrew for mac, binary release for linux
Input Yaml fields.yaml:
global: {}
Command
yq eval '.global.test = "val"' fields.yaml
Actual behavior
global: {test: val}
Expected behavior
global: test: val
Additional context If we work with an empty file, or a non-existing key, the format is correct:
$ yq eval '.global.test = "val"' empty-fields.yaml global: test: val $ yq eval '.other.test = "val"' fields.yaml global: {} other: test: val
Also, as a workaround, we can parse it to json and back to yaml and the format is correct:
$ yq eval '.global.test = "val"' fields.yaml -o json | yq -P '.' - global: test: val
The text was updated successfully, but these errors were encountered:
Yeah this is a side effect of yq trying to maintain the styling used in the document. I'm surprised helm doesn't like it as it's perfectly valid yaml.
yq
I'll look into making it a bit smarter for scenarios like this, till then you can:
yq -P '.global.test = "val"' fields.yaml
Sorry, something went wrong.
Fixed in 4.24.5
I want to have the empty map converted to a single line definition when updated. Seems there is no way to achieve this now.
I have branches with commits changing something like:
foo1: bar: true
and
foo2: bar: true
Now merging these automatically would result in (depending on which way)
foo1: foo2: bar: true
If I could maintain the yaml in a single line, then I could work around this issue. The merge would be:
foo1: { bar: true } foo2: { bar: true }
I expected combining these commands would preserve the inline format:
yq e -i ".foo1 = {}" myvalues.yaml yq e -i ".foo1.bar = true" myvalues.yaml
No branches or pull requests
Describe the bug
As described in https://mikefarah.gitbook.io/yq/operators/assign-update#update-empty-object-and-array, updating a file with an existing empty map results in a one-liner yaml. In our use case, this makes helm template to break.
Version of yq: 4.24.2
Operating system: tested on mac and linux
Installed via: homebrew for mac, binary release for linux
Input Yaml
fields.yaml:
Command
Actual behavior
Expected behavior
Additional context
If we work with an empty file, or a non-existing key, the format is correct:
Also, as a workaround, we can parse it to json and back to yaml and the format is correct:
The text was updated successfully, but these errors were encountered: