Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Script to automate bumping etcd
Browse files Browse the repository at this point in the history
* Does not remove previous etcd from blobs

[#151767405]

Signed-off-by: Iain Sproat <[email protected]>
  • Loading branch information
Akshay Mankar authored and iainsproat committed Nov 27, 2017
1 parent 23ddd4b commit fdcb03e
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions scripts/bump_etcd_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -e

main() {
local staging_dir etcd_version binary
etcd_version=$1

if [ $# -ne 1 ]; then
echo "Usage: $(basename "$0") [ETCD VERSION]"
exit 1
fi

staging_dir=$(mktemp -d)
binary="etcd-v${etcd_version}-linux-amd64.tar.gz"

trap '{ rm -rf "$staging_dir"; }' EXIT

remove_previous_blob
download "${binary}" "${staging_dir}" "${etcd_version}"
add_blob "${binary}" "${staging_dir}" "${etcd_version}"

download_private_yml
upload_blobs
remove_private_yml
}

remove_previous_blob() {
local previous_blob_name
previous_blob_name=$(bosh blobs --column path | grep etcd )
bosh remove-blob "${previous_blob_name}"
}
download() {
local binary_name staging_dir etcd_version
binary_name="$1"
staging_dir="$2"
etcd_version="$3"

wget -O "${staging_dir}/${binary_name}" "https://github.com/coreos/etcd/releases/download/v${etcd_version}/${binary_name}"
}

add_blob() {
local binary_name blob_name staging_dir
binary_name="$1"
staging_dir="$2"

bosh add-blob "${staging_dir}/${binary_name}" "etcd/${binary_name}"
}

download_private_yml() {
local NOTE_ID=8672077019646392820
lpass show --note ${NOTE_ID} > ./config/private.yml
}

upload_blobs() {
bosh upload-blobs
}

remove_private_yml() {
rm ./config/private.yml
}

main "$@"

0 comments on commit fdcb03e

Please sign in to comment.