Filter the path based in search #1374
-
Not sure whether what I am asking is supported or not but in all my searches to documentation yield nothing, that's why I am not adding feature_requst here is my input yaml file
All I want is the find and replace the
And the structure and key's to find the string is dynamic. I tried
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Had to think about this one - and I realised that to do it - you need a yq '(.. | select(tag == "!!str" and test("ghcr.io/junaid18183"))) as $i ireduce({}; setpath($i | path; $i | sub("ghcr.io", "docker.io"))) file.yaml Explanation:
You won't be able to do this until I release a new version (4.28+) |
Beta Was this translation helpful? Give feedback.
Had to think about this one - and I realised that to do it - you need a
setpath
operator likejq
- whichyq
doesn't yet have. I will add it to the next release, then you will be able to:yq '(.. | select(tag == "!!str" and test("ghcr.io/junaid18183"))) as $i ireduce({}; setpath($i | path; $i | sub("ghcr.io", "docker.io"))) file.yaml
Explanation:
(.. | select(tag == "!!str" and test("ghcr.io/junaid18183"))
setpath($i | path ; ...
Yo…