@@ -20,6 +20,18 @@ guard-positive-single-digit-integer-NODE_COUNT: guard-NODE_COUNT
2020 exit 1; \
2121 fi
2222
23+ validate-node-ix0% : .env
24+ @if ! echo " $* " | grep --quiet --extended-regexp ' ^[0-9]+$$' ; then \
25+ echo " Node index $* must be a positive integer" ; \
26+ exit 1; \
27+ fi
28+
29+ @set -o allexport; . $<; set +o allexport; \
30+ if [ "$*" -lt 1 ] || [ "$*" -gt "$$RABBIT_CLUSTER_NODE_COUNT" ]; then \
31+ echo "Node index $* is out of range 1..$$RABBIT_CLUSTER_NODE_COUNT"; \
32+ exit 1; \
33+ fi
34+
2335#
2436# Cluster level
2537#
@@ -73,19 +85,17 @@ stop-all-nodes:
7385# Rabbit Node level
7486#
7587
76- # TODO: validate node index is within boundaries
77-
78- start-node0% : .stack.node0% .yml
88+ start-node0% : validate-node-ix0% .stack.node0% .yml
7989 @STACK_NAME=$(call create_rabbit_node_name,$* ) ; \
8090 if docker stack ls --format ' {{.Name}}' | grep --silent " $$ STACK_NAME" ; then \
8191 echo " Rabbit Node $* is already running, skipping" ; \
8292 else \
8393 echo " Starting Rabbit Node $* ..." ; \
84- docker stack deploy --with-registry-auth --prune --compose-file $< $(call create_rabbit_node_name,$* ) ; \
94+ docker stack deploy --with-registry-auth --prune --compose-file $( word 2, $^ ) $(call create_rabbit_node_name,$* ) ; \
8595 fi
8696
87- update-node0% : .stack.node0% .yml
88- @docker stack deploy --detach=false --with-registry-auth --prune --compose-file $< $(call create_rabbit_node_name,$* )
97+ update-node0% : validate-node-ix0 % .stack.node0% .yml
98+ @docker stack deploy --detach=false --with-registry-auth --prune --compose-file $( word 2, $^ ) $(call create_rabbit_node_name,$* )
8999
90- stop-node0% : .stack.node0 % .yml
100+ stop-node0% : validate-node-ix0 %
91101 @docker stack rm --detach=false $(call create_rabbit_node_name,$* )
0 commit comments