-
Hi!! I'd like some help on a yq command. Some context before: I have a bunch of namespace: test-namespace
releaseName: test-release
paused: false
environment: production
config:
region: us-east-1 I wanted to first add a for yaml in directory/**/spec.yaml; do
yq -i '(select(.environment == "production") | .config.image) = "alpine:latest"' $yaml
done With the above for-loop, only the for yaml in directory/**/spec.yaml; do
yq -i '(select(.environment == "production") | del(.config.image))' $yaml
done And also this: for yaml in directory/**/spec.yaml; do
yq -i '(select(.environment == "production")) | del(.config.image)' $yaml
done The problem is that, even though on The first part to add a new value, I got from this other discussion: #617 EDIT: $ yq --version
yq (https://github.com/mikefarah/yq/) version v4.44.3 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Sure, the issue is that you are first filtering to only include files with environment = production, and then deleting nodes in those matches. Instead do:
The filtering is inside the delete, so it will only delete those matching nodes, or leave the data alone. |
Beta Was this translation helpful? Give feedback.
Sure, the issue is that you are first filtering to only include files with environment = production, and then deleting nodes in those matches.
Instead do:
The filtering is inside the delete, so it will only delete those matching nodes, or leave the data alone.