Merge pull request #9568 from johngmyers/private-upload

Add support for uploading to private buckets
This commit is contained in:
Kubernetes Prow Robot 2020-07-14 07:05:21 -07:00 committed by GitHub
commit 6d9cfac933
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -48,7 +48,7 @@ GCFLAGS?=
# This can be removed when we upgrade to go 1.14
export GOFLAGS=-mod=vendor
UPLOAD_CMD=$(KOPS_ROOT)/hack/upload
UPLOAD_CMD=$(KOPS_ROOT)/hack/upload ${UPLOAD_ARGS}
# Unexport environment variables that can affect tests and are not used in builds
unexport AWS_ACCESS_KEY_ID AWS_REGION AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN CNI_VERSION_URL DNS_IGNORE_NS_CHECK DNSCONTROLLER_IMAGE DO_ACCESS_TOKEN GOOGLE_APPLICATION_CREDENTIALS

View File

@ -1,30 +1,37 @@
#!/bin/bash -e
PUBLIC=1
if [[ "$1" == "--private" ]]; then
PUBLIC=
shift
fi
SRC=$1
DEST=$2
if [[ -z "${SRC}" ]]; then
echo "syntax: $0 <src> <dest>"
echo "syntax: $0 [--private] <src> <dest>"
exit 1
fi
if [[ -z "${DEST}" ]]; then
echo "syntax: $0 <src> <dest>"
echo "syntax: $0 [--private] <src> <dest>"
exit 1
fi
if [[ "${DEST:0:5}" == "s3://" ]]; then
aws s3 sync --acl public-read ${SRC} ${DEST}
aws s3 sync ${PUBLIC:+--acl public-read} ${SRC} ${DEST}
exit 0
fi
if [[ "${DEST:0:5}" == "gs://" ]]; then
gsutil -h "Cache-Control:private,max-age=0" rsync -r -a public-read ${SRC} ${DEST}
gsutil -h "Cache-Control:private,max-age=0" rsync -r ${PUBLIC:+-a public-read} ${SRC} ${DEST}
exit 0
fi
if [[ "${DEST:0:6}" == "oss://" ]]; then
aliyun oss cp --acl public-read -r -f --include "*" ${SRC}/ ${DEST}
aliyun oss cp ${PUBLIC:+--acl public-read} -r -f --include "*" ${SRC}/ ${DEST}
exit 0
fi