Reputation: 105
Given the following snippet from a yml file, how can I change the value of MAINTENANCE_MODE to true?
A solution using mikefarah/yq v4.18+ is preferred.
web:
environment:
- DEBUG=1
- PORT=8082
- MAINTENANCE_MODE=false
- APP_HOME=/opt/app
Upvotes: 0
Views: 4371
Reputation: 36088
If you know that it's in this position, use
yq -i '.web.environment[2] = "MAINTENANCE_MODE=true"' input.yml
If you have to look it up, use
yq -i '.web.environment[] |= sub("^(MAINTENANCE_MODE=).*$", "${1}true")' input.yml
Upvotes: 1