yq
yq copied to clipboard
Option to avoid spaces in generated properties
Please describe your feature request. Currently, when the output is formatted as properties, the equality signs are separated by a single space from both keys and values. Kustomize supports properties files. However, it is not able to process them if they have such whitespace around the equality characters.
I'd like to be able to instruct yq to generate a more compact properties format that is compatible with Kustomize. A clear and concise description of what the request is and what it would solve.
Describe the solution you'd like Given a file application.properties:
foo=bar
And we run a command:
yq --no-spaces '.baz="nix"' application.properties
it could output
foo=bar
baz=nix
Describe alternatives you've considered At the moment, I use sed to remove the whitespace:
yq '.baz="nix"' application.properties | sed 's/\([^ ]*\) = /\1=/g'
yq uses https://github.com/magiconair/properties to decode/encode property files and it currently does not expose an interface to let me control the whitespace.
For now, you could do a custom format, I've just added a new recipe to show how: https://mikefarah.gitbook.io/yq/recipes#export-as-environment-variables-script-or-any-custom-format.
That said, you're sed
expression is simpler (though it could have issues if you had a quoted " = " as a value somewhere..
It's not apparent from the recipe how to handle lists to output them like the -o=props
does. Would be nice to add it.
Besides the recipe doesn't work as described in #1932
Also I don't think this recipe approach will ever be able to handle comments
Also I don't think this recipe approach will ever be able to handle comments
I guess it could after all, but the recipe gets really complex :(
Fixed in 4.42.1