Replies: 1 comment
-
You need to have brackets:
This is to ensure you pass all the matching nodes to the To write the file in place, pass in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been trying for a while (without success) to convert a script that uses yq v3 into v4. The use case here is that we're using yq to do a simple find/replace on values in a kubernetes manifest. For example, given this input:
If my app name is "myapp", then I'd want this output:
The literal
_APP_NAME_
may appear as the value of any node in the document, any number of levels deep.For yq v3, this replaced all occurrences in the document:
yq write --inplace --doc "*" kubernetes-manifest.yaml '**.(.==_APP_NAME_)' myapp
The closest I have gotten with v4 is this, but it produces extra undesirable output, and can't overwrite the file in-place
yq '.. | select(. == "_APP_NAME_") = "myapp"' kubernetes-manifest.yaml > new_file.yaml
The output of this is
So, it does the replacement as desired, but also writes out every value it found afterwards.
How can I suppress all the extra output, and is there a way to have it overwrite the file in place?
Beta Was this translation helpful? Give feedback.
All reactions