From c07fa31fadef73ddcc310ca013edbe684b0c6b23 Mon Sep 17 00:00:00 2001 From: Fredrik Paulsson Date: Wed, 7 Feb 2024 08:35:33 +0100 Subject: [PATCH] feat: support overriding destination as a runtime argument Add a --destination argument to the curl/upload/file template. This allows individual runs to override the destionation. For example, to be able to include a CI pipeline ID as part of the path. --- curl/upload/file/posix.tmpl.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/curl/upload/file/posix.tmpl.sh b/curl/upload/file/posix.tmpl.sh index efa7a3b..0878ef9 100644 --- a/curl/upload/file/posix.tmpl.sh +++ b/curl/upload/file/posix.tmpl.sh @@ -34,12 +34,17 @@ fi # Parse arguments ENDPOINT="${URL}" +DESTINATION="${DST}" while test 0 -ne "${#}"; do case "${1}" in "--url") shift ENDPOINT="${1?Must provide an argument for --url}" ;; + "--destination") + shift + DESTINATION="${1?Must provide an argument for --destination}" + ;; *) printf >&2 'Error: unknown argument: %s\n' "${1}" exit 2 @@ -47,9 +52,9 @@ while test 0 -ne "${#}"; do esac shift done -readonly ENDPOINT +readonly ENDPOINT DESTINATION -printf >&2 "Uploading: %s to %s\n" "${SRC}" "${ENDPOINT}/${DST}" +printf >&2 "Uploading: %s to %s\n" "${SRC}" "${ENDPOINT}/${DESTINATION}" # Do the upload "${RUNFILES}/${CURL}" \ @@ -59,4 +64,4 @@ printf >&2 "Uploading: %s to %s\n" "${SRC}" "${ENDPOINT}/${DST}" --retry "${RETRY}" \ --retry-delay "${RETRY_DELAY}" \ --upload-file "${RUNFILES}/${SRC}" \ - "${ENDPOINT}/${DST}" + "${ENDPOINT}/${DESTINATION}" -- GitLab