Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions dev/registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down