From 26a4f20f6cc602ea65f3bb9ce0184c214b4394d1 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 14 Jun 2024 18:06:51 +0000 Subject: [PATCH] scripts/deploy: factor out a `deployHelper` to make `variant=all` usable *without* `host=all` --- scripts/deploy | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/scripts/deploy b/scripts/deploy index c3379439..c51d9c78 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -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:"