-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from pb82/optional-secrets
remove mounts for gpg and s3 secrets
- Loading branch information
Showing
5 changed files
with
98 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,55 @@ | ||
#required env vars: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_S3_BUCKET_NAME | ||
#optional env vars: AWS_S3_BUCKET_SUFFIX | ||
function check_backup_enabled { | ||
local result=$(oc get secret -n default ${BACKEND_SECRET_NAME} -o template --template='{{.metadata.name}}') | ||
if [[ "$result" == "${BACKEND_SECRET_NAME}" ]]; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
function get_s3_bucket_name { | ||
echo "`oc get secret -n default ${BACKEND_SECRET_NAME} -o jsonpath='{.data.AWS_S3_BUCKET_NAME}' | base64 --decode`" | ||
} | ||
|
||
function get_s3_bucket_suffix { | ||
echo "`oc get secret -n default ${BACKEND_SECRET_NAME} -o jsonpath='{.data.AWS_S3_BUCKET_SUFFIX}' | base64 --decode`" | ||
} | ||
|
||
function get_s3_key_id { | ||
echo "`oc get secret -n default ${BACKEND_SECRET_NAME} -o jsonpath='{.data.AWS_ACCESS_KEY_ID}' | base64 --decode`" | ||
} | ||
|
||
function get_s3_access_key { | ||
echo "`oc get secret -n default ${BACKEND_SECRET_NAME} -o jsonpath='{.data.AWS_SECRET_ACCESS_KEY}' | base64 --decode`" | ||
} | ||
|
||
function upload_archive { | ||
file_list=$1 | ||
datestamp=$2 | ||
check_backup_enabled | ||
if [[ $? -eq 1 ]]; then | ||
echo "==> backend secret not found. Skipping" | ||
return 0 | ||
fi | ||
|
||
local file_list=$1 | ||
local datestamp=$2 | ||
|
||
local AWS_S3_BUCKET_NAME=$(get_s3_bucket_name) | ||
local AWS_S3_BUCKET_SUFFIX="$(get_s3_bucket_suffix)" | ||
local AWS_ACCESS_KEY_ID="$(get_s3_key_id)" | ||
local AWS_SECRET_ACCESS_KEY="$(get_s3_access_key)" | ||
|
||
if [[ "$AWS_S3_BUCKET_SUFFIX" ]]; then | ||
bucket_folder="$3/$AWS_S3_BUCKET_SUFFIX" | ||
else | ||
else | ||
bucket_folder=$3 | ||
fi | ||
|
||
for fname in $file_list; do | ||
s3cmd put --progress $fname "s3://$AWS_S3_BUCKET_NAME/$bucket_folder/$datestamp/$(basename $fname)" | ||
for fname in ${file_list}; do | ||
s3cmd put --access_key ${AWS_ACCESS_KEY_ID} --secret_key ${AWS_SECRET_ACCESS_KEY} --progress ${fname} "s3://$AWS_S3_BUCKET_NAME/$bucket_folder/$datestamp/$(basename ${fname})" | ||
rc=$? | ||
if [ $rc -ne 0 ]; then | ||
echo "==> Upload $name: FAILED" | ||
if [[ ${rc} -ne 0 ]]; then | ||
echo "==> Upload $fname: FAILED" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters