最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

yq: compose new keyvalue depending on value of other keys - Stack Overflow

programmeradmin3浏览0评论

This is the input:

- hostname: rk089-s11
  compute: false
  control: true
  master: false
- hostname: rk090-s11
  compute: false
  control: true
  master: true

I am trying to get this output:

- hostname: rk089-s11
  role: control
- hostname: rk090-s11
  role: control,master

I tried this:

yq -r '.[] |
[
    {
    "hostname": .hostname,
    "role": (
        ( ( pute == true ) | "compute," ) +
        ( ( .control == true ) | "control," ) +
        ( ( .master == true ) | "master," )
    )
    }
]'|sed 's/,$//'

but I only got this

发布评论

评论列表(0)

  1. 暂无评论