问题描述
我想以 repository:tag 格式检索在 cmp
部分中不包含 repository
的所有图像的列表。
我正在尝试使用 yq
,但遇到的问题很少。
我的yaml文件结构:
actions:
install: ...
uninstall: ...
images:
foo:
imageType:"docker"
repository: localhost:3000/cmp/foo
tag: latest
bar:
imageType:"docker"
repository: localhost:3000/bar
tag: latest
fizz:
imageType:"docker"
repository: localhost:3000/fizz
tag: latest
我的 Powershell 脚本:
$keys = yq eval 'del(.images | .. | select(.repository == """*cmP*""")) | .images | keys' $porterPath
foreach($key in $keys) {
$key = $key.Replace("- ","") #All elements of $keys need to be strip from "- "
$repository = yq eval ".images | .$key | .repository"
$tag = yq eval ".images | .$key | .tag"
$image = $repository":"$tag
writetoFile($image)
}
第一个 yq 表达式是将 - repository
添加到 $keys
中的输出列表的末尾,因此它看起来像这样:
- bar
- fizz
- repository
为什么我在 - repository
的末尾得到 $keys
?
有没有更好的方法用 yq 转换 yaml 以获得输出列表包含: 存储库:标签?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)