Skip to content

Commit

Permalink
Fix validate.sh variables defaults in guest scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dimikot committed Aug 26, 2024
1 parent ae98435 commit 2db6c0d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions docker/ci-runner/root/entrypoint.01-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,55 @@
#
set -u -e

export GH_TOKEN
if [[ "${GH_TOKEN:=}" == "" ]]; then
say "GH_TOKEN must be set."
exit 1
fi

export GH_REPOSITORY
if [[ "${GH_REPOSITORY:=}" != */* ]]; then
say "GH_REPOSITORY must be set, and the format should be {owner}/{repo}."
exit 1
fi

export GH_LABELS
if [[ "${GH_LABELS:=}" == "" ]]; then
say "GH_LABELS must be set."
exit 1
fi

export TZ
if [[ "${TZ:=}" != "" && ! "$TZ" =~ ^[-+_/a-zA-Z0-9]+$ ]]; then
say "If TZ is passed, it must be a valid TZ Idenfitier from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"
exit 1
fi

export FORWARD_HOST
if [[ "${FORWARD_HOST:=}" != "" && ! "$FORWARD_HOST" =~ ^[-.[:alnum:]]+(:[0-9]+)?$ ]]; then
say "If FORWARD_HOST is passed, it must be a hostname."
exit 1
fi

export FORWARD_PORTS
if [[ "${FORWARD_PORTS:=}" != "" && ! "$FORWARD_PORTS" =~ ^([[:space:]]*[0-9]+(/tcp|/udp)?[[:space:]]*)+$ ]]; then
echo 'If FORWARD_PORTS is passed, it must be in the form of (example): "123 456/udp 789/tcp".';
exit 1
fi

export CI_STORAGE_HOST
if [[ "${CI_STORAGE_HOST:=}" != "" && ! "$CI_STORAGE_HOST" =~ ^([-.[:alnum:]]+@)?[-.[:alnum:]]+(:[0-9]+)?$ ]]; then
say "If CI_STORAGE_HOST is passed, it must be in the form of [user@]host[:port]."
exit 1
fi

export BTIME
if [[ "${BTIME:=}" != "" && ! "$BTIME" =~ ^[0-9]+$ ]]; then
say "If BTIME is passed, it must be a number (boot timestamp)."
exit 1
fi

export DEBUG_SHUTDOWN_DELAY_SEC
if [[ "${DEBUG_SHUTDOWN_DELAY_SEC:=}" != "" && ! "$DEBUG_SHUTDOWN_DELAY_SEC" =~ ^[0-9]+$ ]]; then
say "If DEBUG_SHUTDOWN_DELAY_SEC is passed, it must be a number."
exit 1
Expand Down
4 changes: 2 additions & 2 deletions docker/ci-scaler/root/entrypoint.01-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
#
set -u -e

export ASGS
if [[ "${ASGS:=}" != "" && "${GH_TOKEN:=}" == "" ]]; then
say "When ASGS is set, GH_TOKEN must also be set."
exit 1
fi

if [[ "${ASGS:=}" != "" && "$ASGS" != */*:*:* ]]; then
say "If ASGS is set, its format should be a space-delimited list of {owner}/{repo}:{label}:{asg_name}."
exit 1
fi

if [[ "$ASGS" == "" ]]; then
say "For this container to operate, ASGS environment variable should be passed. The container will start, but it'll do nothing, which may be fine in dev environment."
fi

export DOMAIN
if [[ "${DOMAIN:=}" != "" && "$DOMAIN" != *.* ]]; then
say "If DOMAIN is set, it should be a fully qualified domain name."
exit 1
Expand Down
1 change: 1 addition & 0 deletions docker/compose-up-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -e

echo "Building & booting containters on the local laptop for debugging purposes..."

# This is for debugging/illustration purposes only.
btime=1719410000
if [[ "$OSTYPE" == darwin* ]]; then
btime=$(sysctl -n kern.boottime | awk '{print $4}' | tr -d ',')
Expand Down

0 comments on commit 2db6c0d

Please sign in to comment.