Merge pull request #885 from samalba/fix-s3-cache

stdlib/aws/s3: replaced sync with cp by default to avoid cache issues
This commit is contained in:
Sam Alba 2021-08-13 22:53:36 +02:00 committed by GitHub
commit 766fe6570c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,9 @@ import (
// Always write the object to S3
always: *true | false @dagger(input)
// Upload method
uploadMethod: *"cp" | "sync"
// URL of the uploaded S3 object
url: {
string
@ -49,6 +52,7 @@ import (
if delete {
OPT_DELETE: "1"
}
UPLOAD_METHOD: uploadMethod
}
mount: "/source": from: source
@ -62,12 +66,22 @@ import (
"-c",
#"""
opts=()
if [ -d /source ]; then
op=sync
fi
case "$UPLOAD_METHOD" in
sync)
[ -n "$OPT_DELETE" ] && opts+="--delete"
opts+="--exact-timestamps"
;;
cp)
opts+="--recursive"
;;
*)
echo "not supported command"
exit 1
;;
esac
[ -n "$OPT_CONTENT_TYPE" ] && opts+="--content-type $OPT_CONTENT_TYPE"
[ -n "$OPT_DELETE" ] && opts+="--delete"
aws s3 sync ${opts[@]} /source "$TARGET"
aws s3 "$UPLOAD_METHOD" ${opts[@]} /source "$TARGET"
echo -n "$TARGET" \
| sed -E 's=^s3://([^/]*)/=https://\1.s3.amazonaws.com/=' \
> /url