Last active
February 2, 2021 19:30
-
-
Save samalba/6cbb8f90c6bd49f116e4fe562e45eddf to your computer and use it in GitHub Desktop.
Copy a BL stack
This file contains hidden or 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 | |
if [ "$#" -lt 3 ]; then | |
echo "Usage: $0 workspace from-stack to-stack" | |
exit 1 | |
fi | |
set -eu | |
stackSrc="$2" | |
stackTo="$3" | |
cmd="bl --workspace $1 --stack-admin" | |
config="$($cmd --stack "$stackSrc" get)" | |
getComponentType() { | |
$cmd --stack "$stackSrc" component list | grep "$1" | awk '{print $2}' | |
} | |
bl stack create "$stackTo" | |
for c in $($cmd --stack "$stackSrc" component list | tail -n +2 | awk '{print $1}'); do | |
componentName="$(echo "$c" | tr '[:upper:]' '[:lower:]')" | |
echo "$config" | \ | |
jq --arg c "$c" '.Component[$c].Settings' | \ | |
$cmd --stack "$stackTo" install -f - "$componentName" "$(getComponentType "$c")" || true | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment