【发布时间】:2021-05-03 01:04:04
【问题描述】:
我有一个 bash 脚本,它使用 artifacthub.io annotations 更新 helm yaml 文件。但是,我的脚本正在使用变量,我相信这些变量需要命令使用双引号而不是单引号。此外,artifacthub.io 会导致 artifact 和 io 分离的问题。我可以使用哪个yq 命令来更新changes 和images 注释?我也尝试过使用sed 无济于事。
annotations:
artifacthub.io/changes: |
- Fixed linting issues.
artifacthub.io/images: |
- name: transmission
image: ghcr.io/linuxserver/transmission:3.00-r0-ls75
我尝试了以下类似的方法,但没有成功。
image=foo
yq e ".annotations."artifacthub.io/images"=\"${image}\"" -i "${chart_file_path}"
【问题讨论】:
-
name和image字段不是单独的记录,而是多行字符串的一部分 - YAML 世界中的“块”文字。见 - yaml-multiline.info -
您将无法直接操作这些字段,而是使用您所需的值形成一个多行字符串。跑
yq e '.. style="double"' yaml自己看看