Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for uploading to private buckets #9568

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions hack/upload
Original file line number Diff line number Diff line change
@@ -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

Expand Down