From 35fb7e0cfcd68acb6bb17d838b747bd939caa91e Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Fri, 13 Aug 2021 13:37:24 -0700 Subject: [PATCH] stdlib/aws/s3: replaced sync with cp by default to avoid cache issues Signed-off-by: Sam Alba --- stdlib/aws/s3/s3.cue | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/stdlib/aws/s3/s3.cue b/stdlib/aws/s3/s3.cue index 06772388..3235f713 100644 --- a/stdlib/aws/s3/s3.cue +++ b/stdlib/aws/s3/s3.cue @@ -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