From 37d954e304ba95b164af34ed1a1141f5417c4027 Mon Sep 17 00:00:00 2001 From: Martin Lablans Date: Tue, 31 May 2022 13:56:12 +0200 Subject: [PATCH] New function assertVarsNotEmpty() --- lib/functions.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/functions.sh b/lib/functions.sh index c524dd4..3d5a88f 100755 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -80,6 +80,23 @@ fetchVarsFromVaultByFile() { return 0 } +assertVarsNotEmpty() { + MISSING_VARS="" + + for VAR in $@; do + if [ -z "${!VAR}" ]; then + MISSING_VARS+="$VAR " + fi + done + + if [ -n "$MISSING_VARS" ]; then + log "ERROR" "Mandatory variables not defined: $MISSING_VARS" + return 1 + fi + + return 0 +} + ##Setting Network properties export HOSTIP=$(MSYS_NO_PATHCONV=1 docker run --rm --add-host=host.docker.internal:host-gateway ubuntu cat /etc/hosts | grep 'host.docker.internal' | awk '{print $1}'); export HOST=$(hostname)