Description
Describe the bug
Error: 3:5: lexer: invalid input text "if .key == "topo..."
Version of yq: 4.X.X
Operating system: mac/linux/windows/....
Installed via: docker/binary release/homebrew/snap/...
mac homebrew
yq (https://github.com/mikefarah/yq/) version v4.45.4
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
input.yml:
spec:
spec:
requirements:
- key: "kubernetes.io/arch"
operator: In
values: ["amd64"]
- key: "topology.kubernetes.io/zone"
operator: In
values: ["eu-west-1a", "eu-west-1c"]
output.yml:
spec:
spec:
requirements:
- key: "kubernetes.io/arch"
operator: In
values: ["amd64"]
- key: "topology.kubernetes.io/zone"
operator: In
values: ["eu-west-1b", "eu-west-1a"]
Command
The command you ran:
AZS='["eu-west-1b","eu-west-1a"]'
yq -i '.spec.template.spec.requirements[] |= if .key == "topology.kubernetes.io/zone" then .values = (env.AZS | from_json) else . end' argo-apps/karpenter/provisioners/base-nodepool.yaml
Actual behavior
Error: 1:39: lexer: invalid input text "if .key == \"topo..."
Expected behavior
It should replace whatever is in the values in the key: "topology.kubernetes.io/zone" with: ["eu-west-1b", "eu-west-1a"]
Additional context
I was able to get it to work by using the below command (simple array lookup) but what if someone juggles these around? Would be nice to lookup by key but obviously I am doing it wrong or it is unsupported.
yq -i '.spec.template.spec.requirements[1].values = env(AZS)' argo-apps/karpenter/provisioners/base-nodepool.yaml