Returning the first field value if Regex match is true #403
Unanswered
csotiistvan
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
tldr;
How to to this in JSONata:
curl -sL https://api.github.com/repos/prometheus-community/helm-charts/releases | grep "tag_name\": \"kube-" | head -1
I'm trying to accomplish a seemingly simple thing, but just can't seem to make it work, no matter what I try.
Background: Wanted to make a quick and dirty panel that shows the latest version of applications we use. I can query the Github API (/repos/prometheus-community/helm-charts/releases), but a bunch of different charts are in the same repo, so simply checking the /latest is not enough. I would like to see the latest 'tag_name' that contains either /kube/ or /black/. No matter what expression I try, mostly I get the dreaded Fields have different lengths error. Even on queries that work on JSONata playground I get this error, so really can't figure out what to do.
$.[$contains(tag_name, /kube.*/i)]
will return true/false for the matched items on the playground, while$.$contains(tag_name, /kube.*/i) ? $.tag_name : "Not found"
returns alltag_name
values is at least one is matched. How could this be refined to just return the first matchedtag_name
? And how could I circumvent the Fields have different lengths error?Any assistance would be highly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions