如何使用 Mike Farah 的 YQ v4 更新具有特殊字符的字段。
例如在下面操作:
containers:
- name: flyway
image: xx.dkr.ecr.eu-west-1.amazonaws.com/testimage:60
尝试错误:
$ yq e ".spec.template.spec.containers[0].image=xx.dkr.ecr.eu-west-1.amazonaws.com/testimage:61" flyway.yaml
Error: Bad expression, please check expression syntax
$ yq e ".spec.template.spec.containers[0].image=xx\.dkr\.ecr\.eu-west-1\.amazonaws\.com\/testimage:61" flyway.yaml
Error: Parsing expression: Lexer error: could not match text starting at 1:53 failing at 1:54.
unmatched text: "\\"
#########
$ echo $image
xx.dkr.ecr.eu-west-1.amazonaws.com/testimage:61
$ yq e ".spec.template.spec.containers[0].image=$image" flyway.yaml
Error: Bad expression, please check expression syntax
没有找到任何解释特殊字符的任何转义字符的文件。