Skip to content
Snippets Groups Projects
Commit 140c558b authored by thelamer's avatar thelamer
Browse files

install and use jq to parse json returns

parent 762eac73
No related branches found
No related tags found
No related merge requests found
...@@ -12,11 +12,13 @@ if [ ! -f /usr/bin/curl ]; then ...@@ -12,11 +12,13 @@ if [ ! -f /usr/bin/curl ]; then
## Ubuntu ## Ubuntu
apt-get update apt-get update
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
curl curl \
jq
elif [ -f /sbin/apk ]; then elif [ -f /sbin/apk ]; then
# Alpine # Alpine
apk add --no-cache \ apk add --no-cache \
curl curl \
jq
fi fi
fi fi
...@@ -30,19 +32,14 @@ get_blob_sha () { ...@@ -30,19 +32,14 @@ get_blob_sha () {
--location \ --location \
--request GET \ --request GET \
--header "Authorization: Bearer $2" \ --header "Authorization: Bearer $2" \
$3 |\ $3 | jq -r '.layers[0].digest'
grep -A4 'layers' |\
grep -m1 'digest' |\
awk -F'"' '{print $4}'
else else
curl \ curl \
--silent \ --silent \
--location \ --location \
--request GET \ --request GET \
--header "Authorization: Bearer $2" \ --header "Authorization: Bearer $2" \
$3 |\ $3 | jq -r '.fsLayers[0].blobSum'
grep -m1 "blobSum" |\
awk -F'"' '{print $4}'
fi fi
} }
...@@ -101,8 +98,7 @@ for DOCKER_MOD in "${DOCKER_MODS[@]}"; do ...@@ -101,8 +98,7 @@ for DOCKER_MOD in "${DOCKER_MODS[@]}"; do
--silent \ --silent \
--header 'GET' \ --header 'GET' \
"${AUTH_URL}" \ "${AUTH_URL}" \
| grep -m1 "token" \ | jq -r '.token' \
| awk -F'"' '{print $4}' \
)" )"
# Determine first and only layer of image # Determine first and only layer of image
SHALAYER=$(get_blob_sha "${MODE}" "${TOKEN}" "${MANIFEST_URL}") SHALAYER=$(get_blob_sha "${MODE}" "${TOKEN}" "${MANIFEST_URL}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment