Skip to content

Instantly share code, notes, and snippets.

@TiloGit
Created April 23, 2024 16:51
Show Gist options
  • Save TiloGit/21e19fbd3599d3a7881924258f637538 to your computer and use it in GitHub Desktop.
Save TiloGit/21e19fbd3599d3a7881924258f637538 to your computer and use it in GitHub Desktop.
YQ examples
###just soem YQ examples
##working
yq e '.spec.template.spec.containers[]' keycloak.yaml
###
yq e '.spec.template.spec.containers[].env[] | select(.name == "KEYCLOAK_ADMIN_PASSWORD") | .value' keycloak.yaml
##update
yq -r '(.spec.template.spec.containers[].env[] | select(.name == "KEYCLOAK_ADMIN_PASSWORD") | .value) = "myNewPass"' keycloak.yaml
wget -q -O - https://raw.githubusercontent.com/keycloak/keycloak-quickstarts/latest/kubernetes/keycloak.yaml | \
yq '(.spec.template.spec.containers[].env[] | select(.name == "KEYCLOAK_ADMIN_PASSWORD") | .value) = "myNewPass"' - | \
yq e '.spec.template.spec.containers[]' -
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment