Last active
June 19, 2020 22:49
-
-
Save ncknt/37b1743111eb727bcd81e21dffda90d6 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# This script download a version of Armory's BOM to a local directory | |
# Usage: download.sh <version name> <destination path> | |
# Prerequisites: | |
# - aws cli: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html | |
# - access to public s3 installed (no need for credentials) | |
# - write access to the destination path | |
# Change that | |
NEW_DOCKER_REGISTRY="docker.io/armory" | |
PGM=$0 | |
VERSION=$1 | |
DESTINATION_DIR=$2 | |
ARMORY_BUCKET="halconfig" | |
ARMORY_BUCKET_REGION="us-west-2" | |
SERVICES="clouddriver echo gate orca igor deck fiat front50 kayenta rosco monitoring-daemon dinghy terraformer" | |
if [[ $# -lt 2 ]]; then | |
echo "Usage: ${PGM} <version name> <destination path>" | |
exit 1 | |
fi | |
if [[ -f $DESTINATION_DIR ]]; then | |
echo "${DESTINATION_DIR} is a file." | |
exit 1 | |
fi | |
mkdir -p ${DESTINATION_DIR}/bom | |
bom="${DESTINATION_DIR}/bom/${VERSION}.yml" | |
aws s3 cp --no-sign-request --region ${ARMORY_BUCKET_REGION} s3://${ARMORY_BUCKET}/bom/${VERSION}.yml ${bom} | |
for svc in $SERVICES; do | |
sv=$(grep -A 1 ${svc} ${bom} | awk '/version/ {print $2}' | cut -f1 -d"-") | |
sdir="$DESTINATION_DIR/profiles/${svc}/${sv}" | |
mkdir -p $sdir | |
aws s3 cp --no-sign-request --region ${ARMORY_BUCKET_REGION} --recursive --include "*" s3://${ARMORY_BUCKET}/profiles/${svc}/${sv}/ $sdir | |
done | |
sed -i '' "s/docker.io\\/armory/$(echo $NEW_DOCKER_REGISTRY | sed 's/\//\\\//g')/g" $bom | |
echo "\nVersion ${version} is ready to be uploaded to your private bucket." | |
echo "For example, with \"aws cp --recursive\" or \"gsutil cp -m -r ...\"" | |
alternative approach for Line 34 using yq
sv=$(yq r ${bom} 'services.'${svc}'.version')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ncknt the new bom format added 'commit' causing the grep & awk to fail on line 34
e.g.