Skip to content

Commit

Permalink
Fix for gnu xargs and send --verbose to other commands (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnybod authored Aug 16, 2024
1 parent dc2098a commit a32f3bf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions oci/private/push.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ readonly TAGS_FILE="{{tags}}"
readonly FIXED_ARGS=({{fixed_args}})
readonly REPOSITORY_FILE="{{repository_file}}"

VERBOSE=""

REPOSITORY=""
if [ -f $REPOSITORY_FILE ] ; then
REPOSITORY=$(tr -d '\n' < "$REPOSITORY_FILE")
Expand All @@ -24,6 +26,9 @@ ARGS=()

while (( $# > 0 )); do
case $1 in
(-v|--verbose)
VERBOSE="--verbose"
shift;;
(-t|--tag)
TAGS+=( "$2" )
shift
Expand All @@ -47,13 +52,13 @@ done
DIGEST=$("${JQ}" -r '.manifests[0].digest' "${IMAGE_DIR}/index.json")

REFS=$(mktemp)
"${CRANE}" push "${IMAGE_DIR}" "${REPOSITORY}@${DIGEST}" "${ARGS[@]+"${ARGS[@]}"}" --image-refs "${REFS}"
"${CRANE}" push ${VERBOSE} "${IMAGE_DIR}" "${REPOSITORY}@${DIGEST}" "${ARGS[@]+"${ARGS[@]}"}" --image-refs "${REFS}"

for tag in "${TAGS[@]+"${TAGS[@]}"}"
do
"${CRANE}" tag $(cat "${REFS}") "${tag}"
"${CRANE}" tag ${VERBOSE} $(cat "${REFS}") "${tag}"
done

if [[ -e "${TAGS_FILE:-}" ]]; then
cat "${TAGS_FILE}" | xargs -n1 "${CRANE}" tag $(cat "${REFS}")
cat "${TAGS_FILE}" | xargs --no-run-if-empty -n1 "${CRANE}" tag ${VERBOSE} $(cat "${REFS}")
fi

0 comments on commit a32f3bf

Please sign in to comment.