improve error handling for unset env vars

This commit is contained in:
Kenneth Bingham
2021-04-06 17:54:34 -04:00
parent 99199230e6
commit 01ef2fd5ff
2 changed files with 16 additions and 6 deletions
+3
View File
@@ -1,3 +1,6 @@
# enrollments in-use with Docker Compose
*.json
*.jwt
# executable from fetch bins script
/ziti-tunnel
+13 -6
View File
@@ -1,16 +1,23 @@
#!/bin/bash -eu
set -o pipefail
#!/bin/bash
echo "Fetching from Artifactory."
if [ -z "${ARTIFACTORY_BASE_URL}" ]; then ARTIFACTORY_BASE_URL="https://netfoundry.jfrog.io/netfoundry"; fi
if [ -z "${ARTIFACTORY_REPO}" ]; then ARTIFACTORY_REPO="ziti-release"; fi
set -euo pipefail
[[ $# -eq 0 ]] && {
echo "ERROR: need the base name(s) of the executable(s) to fetch e.g. \"ziti-tunnel ...\"." >&2
exit 1
}
: ${ARTIFACTORY_BASE_URL:="https://netfoundry.jfrog.io/netfoundry"}
: ${ARTIFACTORY_REPO:="ziti-release"}
for var in ARTIFACTORY_BASE_URL ARTIFACTORY_REPO ZITI_VERSION; do
if [ -z "${!var}" ]; then
if [ -z "${!var:-}" ]; then
echo "ERROR: ${var} must be set when fetching binaries from Artifactory." >&2
exit 1
fi
done
echo "Fetching from Artifactory."
# map host architecture/os to directories that we use in netfoundry.jfrog.io.
# (our artifact directories seem to align with Docker's TARGETARCH and TARGETOS
# build arguments, which we could rely on if we fully committed to "docker buildx" - see