-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathterraform
More file actions
executable file
·68 lines (56 loc) · 1.54 KB
/
terraform
File metadata and controls
executable file
·68 lines (56 loc) · 1.54 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env sh
set -o errexit
network_mirror() {
cat <<EOF
provider_installation {
network_mirror {
url = "${TF_CLI_NETWORK_MIRROR_URL}"
}
}
EOF
if [ "${TF_CLI_NETWORK_MIRROR_INSECURE_SKIP_VERIFY}" = "true" ]; then
host=$(echo "${TF_CLI_NETWORK_MIRROR_URL}" | awk -F[/:] '{print $4}')
server=$(echo "${host}" | sed -e 's/:[0-9]*$//')
if [ "${host}" = "${server}" ]; then
host="${host}:443"
fi
# from https://go.dev/src/crypto/x509/root_linux.go.
echo quit | openssl s_client -showcerts -servername "${server}" -connect "${host}" 2>/dev/null | openssl x509 -outform PEM >/etc/ssl/certs/ca-cert-"${server}".pem
fi
}
filesystem_mirror() {
if [ -d "${TF_PLUGIN_MIRROR_DIR}" ]; then
excludes=$(find "${TF_PLUGIN_MIRROR_DIR}" -type d -maxdepth 3 -mindepth 3 -exec sh -c 'echo "$1" | sed -e s#$TF_PLUGIN_MIRROR_DIR/##' _ {} \;)
fi
if [ -n "${excludes}" ]; then
# shellcheck disable=SC2016
excludes=$(echo "${excludes}" | sed -e 'H;${x;s/\n/,/g;s/^,//;s/,/",\n "/g;p;};d')
excludes=$(printf "\"%s\"" "${excludes}")
cat <<EOF
provider_installation {
filesystem_mirror {
path = "${TF_PLUGIN_MIRROR_DIR}"
}
direct {
exclude = [
${excludes}
]
}
}
EOF
fi
}
entry() {
if [ ! -f "${HOME}"/.terraformrc ]; then
if [ -n "${TF_CLI_NETWORK_MIRROR_URL}" ]; then
config=$(network_mirror)
else
config=$(filesystem_mirror)
fi
if [ -n "${config}" ]; then
echo "${config}" >"${HOME}"/.terraformrc
fi
fi
exec /bin/terraform "$@"
}
entry "$@"