Skip to content

Commit 8b0a916

Browse files
authored
Improve registry.sh script UX (#1664)
1 parent 8156feb commit 8b0a916

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

dev/registry.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ source $ROOT/dev/config/env.sh
2424
source $ROOT/dev/util.sh
2525

2626
GCR_HOST=${GCR_HOST:-"gcr.io"}
27+
GCP_PROJECT_ID=${GCP_PROJECT_ID:-}
28+
AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID:-}
29+
AWS_REGION=${AWS_REGION:-}
2730

2831
provider="local"
2932
include_slim="false"
@@ -182,6 +185,22 @@ function cleanup_ecr() {
182185
done
183186
}
184187

188+
function validate_env() {
189+
local provider=$1
190+
191+
if [ "$provider" = "aws" ]; then
192+
if [ -z ${AWS_REGION} ] || [ -z ${AWS_ACCOUNT_ID} ]; then
193+
echo "error: environment variables AWS_REGION and AWS_ACCOUNT_ID should be exported in dev/config/env.sh"
194+
exit 1
195+
fi
196+
elif [ "$provider" = "gcp" ]; then
197+
if [ -z ${GCP_PROJECT_ID} ]; then
198+
echo "error: environment variables GCP_PROJECT_ID should be exported in dev/config/env.sh"
199+
exit 1
200+
fi
201+
fi
202+
}
203+
185204
# export functions for parallel command
186205
export -f build_and_push
187206
export -f push
@@ -190,6 +209,9 @@ export -f blue_echo
190209
export -f green_echo
191210
export -f registry_login
192211

212+
# validate environment is correctly set on env.sh
213+
validate_env "$provider"
214+
193215
# usage: registry.sh clean --provider aws|gcp|local
194216
if [ "$cmd" = "clean" ]; then
195217
if [ "$provider" = "aws" ]; then

0 commit comments

Comments
 (0)