Only use one jq process for version output.

This commit is contained in:
redxef 2022-08-29 21:18:28 +02:00
parent 7a75a88da2
commit ab5e2f6420
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
4 changed files with 6 additions and 6 deletions

View file

@ -4,4 +4,4 @@ set -eu
[ -e /opt/resource/common ] && cd /opt/resource
. ./common
jq --null-input --arg version "$(crane digest "$REPOSITORY:$TAG")" '[{"digest": $version}]' | jq -r tostring
jq -r --null-input --arg version "$(crane digest "$REPOSITORY:$TAG")" '[{"digest": $version}] | tostring'

View file

@ -32,7 +32,7 @@ split_repo_domain() {
if [ -z "$domain_part" ]; then
domain_part="$DEFAULT_DOMAIN"
other_part="$other_part"
# other_part="$other_part"
elif echo "$domain_part" | grep -Evq '\.|:' && [ "$domain_part" != 'localhost' ]; then
# ^ docker sourcecode checks if $domain_part == $domain_part.lower() in effect checking if all is lower case
domain_part="$DEFAULT_DOMAIN"

4
src/in
View file

@ -9,6 +9,6 @@ oci_dir="$(mktemp -d)"
crane pull --format=oci "$REPOSITORY:@$(jq -r .version "$INPUT_FILE")" "$oci_dir"
cd "$oci_dir"
tar cf "$1/image.tar" ./*
cd - 1>&2
cd - 1>&2 2>/dev/null
jq .version < "$INPUT_FILE" | jq -r tostring
jq -r '.version | tostring' < "$INPUT_FILE"

View file

@ -9,6 +9,6 @@ IMAGE_REFS_FILE="$(mktemp -t)"
oci_dir="$(mktemp -d)"
cd "$oci_dir"
tar xf "$1/$(jq -r .params.image < "$INPUT_FILE")"
cd - 1>&2
cd - 1>&2 2>/dev/null
crane push "$oci_dir" "$REPOSITORY:$TAG" --image-refs="$IMAGE_REFS_FILE"
jq --null-input --arg version "$(sed 's/^[^@]*@//' < "$IMAGE_REFS_FILE")" '{"digest": $version}' | jq -r tostring
jq -r --null-input --arg version "$(sed 's/^[^@]*@//' < "$IMAGE_REFS_FILE")" '{"digest": $version} | tostring'