From 465e2c2f1c4ff230b7f2742ca70fb7e10a75435c Mon Sep 17 00:00:00 2001 From: Alexander Hans Date: Thu, 17 Oct 2024 15:56:27 +0200 Subject: [PATCH] fix: pass global crane flags to all invocations --- oci/private/push.sh.tpl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/oci/private/push.sh.tpl b/oci/private/push.sh.tpl index b55739d8..f5e4c507 100644 --- a/oci/private/push.sh.tpl +++ b/oci/private/push.sh.tpl @@ -22,12 +22,21 @@ if [[ ${#ALL_ARGS[@]} -gt 0 ]]; then fi TAGS=() + +# global crane flags to be passed with every crane invocation +GLOBAL_FLAGS=() + +# this will hold args specific to `crane push`` ARGS=() while (( $# > 0 )); do case $1 in - (-v|--verbose) - VERBOSE="--verbose" + (--allow-nondistributable-artifacts|--insecure|-v|--verbose) + GLOBAL_FLAGS+=( "$1" ) + shift;; + (--platform) + GLOBAL_FLAGS+=( "--platform" "$2" ) + shift shift;; (-t|--tag) TAGS+=( "$2" ) @@ -52,13 +61,13 @@ done DIGEST=$("${JQ}" -r '.manifests[0].digest' "${IMAGE_DIR}/index.json") REFS=$(mktemp) -"${CRANE}" push ${VERBOSE} "${IMAGE_DIR}" "${REPOSITORY}@${DIGEST}" "${ARGS[@]+"${ARGS[@]}"}" --image-refs "${REFS}" +"${CRANE}" push "${GLOBAL_FLAGS[@]+"${GLOBAL_FLAGS[@]}"}" "${IMAGE_DIR}" "${REPOSITORY}@${DIGEST}" "${ARGS[@]+"${ARGS[@]}"}" --image-refs "${REFS}" for tag in "${TAGS[@]+"${TAGS[@]}"}" do - "${CRANE}" tag ${VERBOSE} $(cat "${REFS}") "${tag}" + "${CRANE}" tag "${GLOBAL_FLAGS[@]+"${GLOBAL_FLAGS[@]}"}" $(cat "${REFS}") "${tag}" done if [[ -e "${TAGS_FILE:-}" ]]; then - cat "${TAGS_FILE}" | xargs -r -n1 "${CRANE}" tag ${VERBOSE} $(cat "${REFS}") + cat "${TAGS_FILE}" | xargs -r -n1 "${CRANE}" tag "${GLOBAL_FLAGS[@]+"${GLOBAL_FLAGS[@]}"}" $(cat "${REFS}") fi