From 3e4c487985a459d9414ec399dbb1ae8c1369fb7e Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 8 Feb 2024 10:25:45 +0000 Subject: [PATCH 1/2] feat(curl_upload_file): allow `--dst` argument alias This mirrors the attribute name, which helps developer experience. --- curl/upload/file/posix.tmpl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curl/upload/file/posix.tmpl.sh b/curl/upload/file/posix.tmpl.sh index 0878ef9..3c78f89 100644 --- a/curl/upload/file/posix.tmpl.sh +++ b/curl/upload/file/posix.tmpl.sh @@ -41,7 +41,7 @@ while test 0 -ne "${#}"; do shift ENDPOINT="${1?Must provide an argument for --url}" ;; - "--destination") + "--dst" | "--destination") shift DESTINATION="${1?Must provide an argument for --destination}" ;; -- GitLab From 85b75a8b88c3a43c762fed16c6a8ffe7d9cc7f44 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 8 Feb 2024 10:55:43 +0000 Subject: [PATCH 2/2] feat(curl_upload_file): add `--directory` argument Allows adding path directory to the composed URL. ``` bazel run -- :upload --dir one --dir two bazel run -- :upload --directory one/two ``` This can be useful to prefix the uploaded file with a CI environment variable: ``` bazel run -- :upload --dir "${CI_PIPELINE_ID}" ``` --- curl/upload/file/posix.tmpl.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/curl/upload/file/posix.tmpl.sh b/curl/upload/file/posix.tmpl.sh index 3c78f89..59ee342 100644 --- a/curl/upload/file/posix.tmpl.sh +++ b/curl/upload/file/posix.tmpl.sh @@ -34,6 +34,7 @@ fi # Parse arguments ENDPOINT="${URL}" +DIRECTORY="/" DESTINATION="${DST}" while test 0 -ne "${#}"; do case "${1}" in @@ -41,6 +42,10 @@ while test 0 -ne "${#}"; do shift ENDPOINT="${1?Must provide an argument for --url}" ;; + "--dir" | "--directory") + shift + DIRECTORY="${DIRECTORY}${1?Must provide an argument for --directory}/" + ;; "--dst" | "--destination") shift DESTINATION="${1?Must provide an argument for --destination}" @@ -52,9 +57,12 @@ while test 0 -ne "${#}"; do esac shift done -readonly ENDPOINT DESTINATION +readonly ENDPOINT DIRECTORY DESTINATION + +COMPOSED="${ENDPOINT}${DIRECTORY}${DESTINATION}" +readonly COMPOSED -printf >&2 "Uploading: %s to %s\n" "${SRC}" "${ENDPOINT}/${DESTINATION}" +printf >&2 "Uploading: %s to %s\n" "${SRC}" "${COMPOSED}" # Do the upload "${RUNFILES}/${CURL}" \ @@ -64,4 +72,4 @@ printf >&2 "Uploading: %s to %s\n" "${SRC}" "${ENDPOINT}/${DESTINATION}" --retry "${RETRY}" \ --retry-delay "${RETRY_DELAY}" \ --upload-file "${RUNFILES}/${SRC}" \ - "${ENDPOINT}/${DESTINATION}" + "${COMPOSED}" -- GitLab