scripts/deploy: factor out a deployHelper to make variant=all usable *without* host=all

This commit is contained in:
Colin 2024-06-14 18:06:51 +00:00
parent 46f5a7e37d
commit 26a4f20f6c

View File

@ -114,22 +114,28 @@ deployOneHost() {
parseArgs "$@"
failedDeploys=()
if [ "$host" = "all" ]; then
for host in moby lappy crappy servo desko; do
if [ "$variant" = "all" ]; then
for variant in -min -light ""; do
deployOneHost "$host" "$variant" || \
failedDeploys+=("$host$variant")
done
else
deployOneHost "$host" "$variant" || \
failedDeploys+=("$host$variant")
fi
done
else
deployOneHost "$host" "$variant" || \
failedDeploys+=("$host$variant")
fi
# deployHelper is like `deployOneHost`,
# but it handles the special cases of `host=all` or `variant=all`,
# and aggregates failed deployments into the `failedDeploys` var.
deployHelper() {
local host="$1"
local variant="$2"
if [ "$host" = "all" ]; then
for host in moby lappy crappy servo desko; do
deployHelper "$host" "$variant"
done
elif [ "$variant" = "all" ]; then
for variant in -min -light ""; do
deployHelper "$host" "$variant"
done
else
deployOneHost "$host" "$variant" || \
failedDeploys+=("$host$variant")
fi
}
deployHelper "$host" "$variant"
if [ "${#failedDeploys[@]}" -ne 0 ]; then
echo "FAILED DEPLOYMENT:"