diff --git a/dev/registry.sh b/dev/registry.sh index 095b88afe9..232db89f5c 100755 --- a/dev/registry.sh +++ b/dev/registry.sh @@ -24,6 +24,9 @@ source $ROOT/dev/config/env.sh source $ROOT/dev/util.sh GCR_HOST=${GCR_HOST:-"gcr.io"} +GCP_PROJECT_ID=${GCP_PROJECT_ID:-} +AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID:-} +AWS_REGION=${AWS_REGION:-} provider="local" include_slim="false" @@ -182,6 +185,22 @@ function cleanup_ecr() { done } +function validate_env() { + local provider=$1 + + if [ "$provider" = "aws" ]; then + if [ -z ${AWS_REGION} ] || [ -z ${AWS_ACCOUNT_ID} ]; then + echo "error: environment variables AWS_REGION and AWS_ACCOUNT_ID should be exported in dev/config/env.sh" + exit 1 + fi + elif [ "$provider" = "gcp" ]; then + if [ -z ${GCP_PROJECT_ID} ]; then + echo "error: environment variables GCP_PROJECT_ID should be exported in dev/config/env.sh" + exit 1 + fi + fi +} + # export functions for parallel command export -f build_and_push export -f push @@ -190,6 +209,9 @@ export -f blue_echo export -f green_echo export -f registry_login +# validate environment is correctly set on env.sh +validate_env "$provider" + # usage: registry.sh clean --provider aws|gcp|local if [ "$cmd" = "clean" ]; then if [ "$provider" = "aws" ]; then