-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathlogin.sh
More file actions
executable file
·49 lines (42 loc) · 1.5 KB
/
login.sh
File metadata and controls
executable file
·49 lines (42 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
######################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# SPDX-License-Identifier: MIT-0 #
######################################################################
if [ "${DEBUG}" == "true" ]; then
set -x
fi
print_help() {
echo ""
echo "Usage: $0"
echo ""
echo " This script assists with logging in to a private container registry."
echo " By default we use Amazon ECR, however the script can be extended to support other registries as needed."
echo " In order to login successfully, the environment in which this script is running, must be configured"
echo " with an IAM role allowing access to ECR in the target AWS account."
echo ""
}
if [ "$1" == "" ]; then
. ./.env
# Login to container registry
case "$REGISTRY_TYPE" in
"ecr")
echo "Logging in to $REGISTRY_TYPE $REGISTRY ..."
CMD="aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY"
if [ "${VERBOSE}" == "true" ]; then
echo "${CMD}"
fi
if [ "${DRY_RUN}" == "false" ]; then
eval "${CMD}"
fi
;;
*)
echo "Automatic login for REGISTRY_TYPE=$REGISTRY_TYPE is not implemented. Please log in manually."
;;
esac
else
print_help
fi
if [ "${DEBUG}" == "true" ]; then
set +x
fi