Skip to content

Instantly share code, notes, and snippets.

@samalba
Last active February 2, 2021 19:30
Show Gist options
  • Save samalba/6cbb8f90c6bd49f116e4fe562e45eddf to your computer and use it in GitHub Desktop.
Save samalba/6cbb8f90c6bd49f116e4fe562e45eddf to your computer and use it in GitHub Desktop.
Copy a BL stack
#!/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