Skip to content

Instantly share code, notes, and snippets.

@glyn
Created February 25, 2020 10:30
Show Gist options
  • Save glyn/947af97aa7f8d463d2b137c15c850afe to your computer and use it in GitHub Desktop.
Save glyn/947af97aa7f8d463d2b137c15c850afe to your computer and use it in GitHub Desktop.
duck typed find and replace using gojq
cat scratch/deployment.yaml | ./gojq --yaml-input --yaml-output '(..|.spec?.containers|values[].image| select(. == "nginx"))|="banana"'
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-deployment
spec:
template:
spec:
containers:
- image: banana
name: nginx
ports:
- containerPort: 80
- image: nginy
name: nginy
ports:
- containerPort: 81
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-deployment
spec:
template:
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
- name: nginy
image: nginy
ports:
- containerPort: 81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment