i want to output two values from this below json.
the value .next
and value of .digest
when .name = "latest"
and architecture = "amd64"
. I got these two working separated from each other but i want both results in one output from one curl command.
{
"count": 685,
"next": "https://hub.docker.com/v2/repositories/grafana/grafana/tags/?page=2&page_size=100",
"previous": null,
"results": [
{
"creator": 4132603,
"id": 190096972,
"images": [
{
"architecture": "amd64",
"features": "",
"variant": null,
"digest": "sha256:1e180fcaede581b8cc8e2ce8bc010daff9c64972023a0faaf226d92bd9840113",
"os": "linux",
"os_features": "",
"os_version": null,
"size": 91402044,
"status": "active",
"last_pulled": "2022-07-06T03:17:56.450051Z",
"last_pushed": "2022-06-28T14:15:09.891118Z"
},
{
"architecture": "arm64",
"features": "",
"variant": "v8",
"digest": "sha256:834e26ec5e5f4e5eb2410147c12b060143906de04f35eb51cae8285e9b646a56",
"os": "linux",
"os_features": "",
"os_version": null,
"size": 81476918,
"status": "active",
"last_pulled": "2022-07-06T09:03:47.33578Z",
"last_pushed": "2022-06-28T14:15:10.030013Z"
},
{
"architecture": "arm",
"features": "",
"variant": "v7",
"digest": "sha256:3bc954cb89f35bdc0705a381ab9b9a49b014074fbc555c61bf7572cb0965f323",
"os": "linux",
"os_features": "",
"os_version": null,
"size": 82128685,
"status": "active",
"last_pulled": "2022-07-06T09:33:22.228128Z",
"last_pushed": "2022-06-28T14:15:10.159549Z"
}
],
"last_updated": "2022-06-28T14:15:10.331474Z",
"last_updater": 2978857,
"last_updater_username": "grafanaci",
"name": "latest",
"repository": 135617,
"full_size": 91402044,
"v2": true,
"tag_status": "active",
"tag_last_pulled": "2022-07-06T09:33:22.228128Z",
"tag_last_pushed": "2022-06-28T14:15:10.331474Z"
},
Command 1
curl -s "https://hub.docker.com/v2/repositories/grafana/grafana/tags/" | jq --raw-output '.results[] | select(.name=="latest").images[] | select(.architecture=="amd64").digest'
result: sha256:1e180fcaede581b8cc8e2ce8bc010daff9c64972023a0faaf226d92bd9840113
Command 2:
curl -s "https://hub.docker.com/v2/repositories/grafana/grafana/tags/" | jq --raw-output '.next'
result: https://hub.docker.com/v2/repositories/grafana/grafana/tags/?page=2
What i want is the two results as one ouput like this:
sha256:1e180fcaede581b8cc8e2ce8bc010daff9c64972023a0faaf226d92bd9840113, https://hub.docker.com/v2/repositories/grafana/grafana/tags/?page=2
But how can i do this?
CodePudding user response:
If you wrap your filter in ()
, the original object will still be available en can be targeted with .next
as done in the example.
Using a ,
, we can pass the input to the next filter.
(.results[] | select(.name=="latest").images[] | select(.architecture=="amd64").digest), .next
"sha256:1e180fcaede581b8cc8e2ce8bc010daff9c64972023a0faaf226d92bd9840113"
"https://hub.docker.com/v2/repositories/grafana/grafana/tags/?page=2&page_size=100"