fix(copyToS3): Upload to S3 only when indicated (#1134)

Co-authored-by: sergargar <sergio@verica.io>
This commit is contained in:
Sergio Garcia
2022-05-12 17:30:49 +02:00
committed by GitHub
parent 39c7d3b69f
commit d60eea5e2f
2 changed files with 16 additions and 19 deletions

View File

@@ -13,23 +13,14 @@
if [[ $OUTPUT_BUCKET ]]; then
# output mode has to be set to other than text
if [[ "${MODES[@]}" =~ "html" ]] || [[ "${MODES[@]}" =~ "csv" ]] || [[ "${MODES[@]}" =~ "json" ]] || [[ "${MODES[@]}" =~ "json-asff" ]]; then
OUTPUT_BUCKET_WITHOUT_FOLDERS=$(echo $OUTPUT_BUCKET | awk -F'/' '{ print $1 }')
# OUTPUT_BUCKET_STATUS=$($AWSCLI s3api head-bucket --bucket "$OUTPUT_BUCKET" 2>&1 || true)
# if [[ -z $OUTPUT_BUCKET_STATUS ]]; then
# echo "$OPTRED ERROR!$OPTNORMAL wrong bucket name or not right permissions."
# exit 1
# else
# need to make sure last / is not set to avoid // in S3
if [[ $OUTPUT_BUCKET != *"/" ]]; then
OUTPUT_BUCKET="$OUTPUT_BUCKET"
else
OUTPUT_BUCKET=${OUTPUT_BUCKET::-1}
fi
# fi
else
echo "$OPTRED ERROR!$OPTNORMAL - Mode (-M) has to be set as well. Use -h for help."
if [[ "${MODES[*]}" =~ "text" ]]; then
echo "$OPTRED ERROR!$OPTNORMAL - Mode (-M) can't be text when using custom output bucket. Use -h for help."
exit 1
else
# need to make sure last / is not set to avoid // in S3
if [[ $OUTPUT_BUCKET == *"/" ]]; then
OUTPUT_BUCKET=${OUTPUT_BUCKET::-1}
fi
fi
fi