PublishImage/scripts/ensure_no_spaces.sh
mrrpnya 9b5294bb7e
Some checks failed
Test Deploy to OCI Registry / deploy (push) Failing after 1m17s
.
2025-03-06 13:39:23 -08:00

19 lines
No EOL
616 B
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# Ensure no spaces are in the input environment variable(s)
# specify the environment variable(s) to validate as an argument (or array of arguments)
# reserve first argument for the environment variable name
ENV_VAR_NAME=$1
for var in "${@:2}"; do
# get the value of the specified environment variable
value=$(eval echo \$$var)
# check if the value has spaces
if [[ $value =~ [[:space:]] ]]; then
echo "❌ Invalid $ENV_VAR_NAME: $value"
echo " $ENV_VAR_NAME must not have spaces"
exit 1
else
echo "$ENV_VAR_NAME is valid: $value"
fi
done