forked from open-telemetry/opentelemetry-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-registry-login.sh
executable file
·91 lines (71 loc) · 1.88 KB
/
docker-registry-login.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash -e
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
export EBPF_NET_SRC="${EBPF_NET_SRC:-$(git rev-parse --show-toplevel)}"
source "${EBPF_NET_SRC}/dev/script/docker-registry-lib.sh"
if [ "$#" -lt 1 ]; then
echo "usage: $0 [options...] registry..."
echo
echo "registry:"
echo " ecr: log in to ECR"
echo " gcr: log in to GCR"
echo " okta: login through the okta plugin"
echo " env: log in to the docker registry auto-detected off the env var EBPF_NET_DOCKER_REGISTRY"
echo " if the variable is unset, no login attempts are made"
echo " the docker registry URL can also be given, in which case its type will be auto-detected"
echo
echo "options:"
echo " --no-vault: do not use a vault app to fetch secrets from"
echo
echo "ERROR: docker regsitry not specified"
fi
use_vault=true
function auto_detected_login {
case "$(detect_docker_registry "$1")" in
none)
echo "no docker registry configured, skipping login"
;;
local)
echo "no login needed for local docker registry '${EBPF_NET_DOCKER_REGISTRY}'"
;;
ecr)
echo "ECR detected at '${EBPF_NET_DOCKER_REGISTRY}'"
ecr_login "${use_vault}"
;;
gcr)
echo "GCR detected at '${EBPF_NET_DOCKER_REGISTRY}'"
gcr_login
;;
okta)
echo "okta detected at '${EBPF_NET_DOCKER_REGISTRY}'"
okta_login
;;
*)
echo "ERROR: unrecognized docker registry '${EBPF_NET_DOCKER_REGISTRY}'"
return 1
;;
esac
}
while [ "$#" -gt 0 ]; do
arg="$1"; shift
case "${arg}" in
--no-vault)
use_vault=false
;;
ecr)
ecr_login "${use_vault}"
;;
gcr)
gcr_login
;;
okta)
okta_login
;;
env)
auto_detected_login "${EBPF_NET_DOCKER_REGISTRY}"
;;
*)
auto_detected_login "${arg}"
;;
esac
done