Fix directory upload on AWS s3

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau 2021-04-22 20:56:06 +02:00
parent d5aa68fe2b
commit 226be80d56
2 changed files with 10 additions and 3 deletions

View File

@ -56,6 +56,9 @@ import (
// Always execute the script? // Always execute the script?
always?: bool always?: bool
// Directory
dir?: dagger.#Artifact
out: { out: {
string string
@ -101,6 +104,9 @@ import (
AWS_PAGER: "" AWS_PAGER: ""
} }
mount: "/cache/aws": "cache" mount: "/cache/aws": "cache"
if dir != _|_ {
mount: "/inputs/source": from: dir
}
}, },
op.#Export & { op.#Export & {
source: export source: export

View File

@ -42,20 +42,21 @@ import (
code: #""" code: #"""
opts="" opts=""
op=cp
if [ -d /inputs/source ]; then if [ -d /inputs/source ]; then
opts="--recursive" op=sync
fi fi
if [ -f /inputs/content_type ]; then if [ -f /inputs/content_type ]; then
opts="--content-type $(cat /inputs/content_type)" opts="--content-type $(cat /inputs/content_type)"
fi fi
aws s3 cp $opts /inputs/source "$(cat /inputs/target)" aws s3 $op $opts /inputs/source "$(cat /inputs/target)"
cat /inputs/target \ cat /inputs/target \
| sed -E 's=^s3://([^/]*)/=https://\1.s3.amazonaws.com/=' \ | sed -E 's=^s3://([^/]*)/=https://\1.s3.amazonaws.com/=' \
> /url > /url
"""# """#
if sourceInline == _|_ { if sourceInline == _|_ {
mount: "/inputs/source": from: source dir: source
} }
} }
} }