Skip to content

extracting nested objects #1772

Answered by bboles
bboles asked this question in Q&A

You must be logged in to vote

After reading the docs more and some hacking around I came up with this:

yq 'select(di == 0) * . + select(.) | .[] | select(has("only")) | { (key): (pick(["only"])) }' .gitlab-ci.only.yml

Output:

dev-esup-api-plan:
  only:
    changes:
      - vpc-dev/nomad-jobs/esup-api/*
dev-esup-api-apply:
  only:
    refs:
      - master
    changes:
      - vpc-dev/nomad-jobs/esup-api/*
dev-ems-api-plan:
  only:
    changes:
      - vpc-dev/nomad-jobs/ems-api/*
dev-ems-api-apply:
  only:
    refs:
      - master
    changes:
      - vpc-dev/nomad-jobs/ems-api/*
dev-ems-daemons-plan:
  only:
    changes:
      - vpc-dev/nomad-jobs/tsup-em/*
...

This gets me the data that I want! One small nit, I wou…

Replies: 1 comment

You must be logged in to vote
0 replies
Answer selected by bboles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant