From 54149525f2e8be2894f8df831bad60c639ed3a5d Mon Sep 17 00:00:00 2001 From: Martin Liu Date: Wed, 7 Jul 2021 15:36:19 -0700 Subject: [PATCH] Add labels to metadata --- assets/in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/in b/assets/in index 3679e24a..511fb7ba 100755 --- a/assets/in +++ b/assets/in @@ -76,6 +76,7 @@ if [ "$skip_download" = "false" ]; then echo "$image_id" > ${destination}/image-id docker inspect $image_id > ${destination}/docker_inspect.json + labels="$(cat ${destination}/docker_inspect.json | jq -r '.[0].Config.Labels // {} | to_entries | map("\(.key)=\(.value)") | join(", ")')" docker run \ --cidfile=/tmp/container.cid \ @@ -102,6 +103,7 @@ jq -n "{ metadata: [ { name: \"repository\", value: $(echo $repository | jq -R .) }, { name: \"tag\", value: $(echo $tag | jq -R .) }, - { name: \"image\", value: $(echo $image_id | head -c 12 | jq -R .) } + { name: \"image\", value: $(echo $image_id | head -c 12 | jq -R .) }, + { name: \"labels\", value: $(echo $labels | jq -R .) } ] }" | jq '{version: .version} + {metadata: [.metadata[] | select(.value != "")]}' >&3