Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for gnu xargs and send --verbose to other commands #672

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading