-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap
More file actions
57 lines (53 loc) · 1.67 KB
/
bootstrap
File metadata and controls
57 lines (53 loc) · 1.67 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
function hashicorp-helper() {
export HASHICORP_HELPER_TAG=${HASHICORP_HELPER_TAG:-$HASHICORP_HELPER_LAUNCH_TAG}
export HASHICORP_HELPER_INTERACTIVE=${HASHICORP_HELPER_INTERACTIVE:-true}
local HASHICORP_HELPER_EXTRA_OPTS=''
if [ "${HASHICORP_HELPER_INTERACTIVE}" == 'true' ]; then
HASHICORP_HELPER_EXTRA_OPTS+=' -it'
fi
# Generate env file args if file present
local env_file='.env.hashicorp'
local env_file_args=''
local additional_envs_args=''
# We do NOT want to use --env-file for docker
# Reason being that if you dont assign a value in the env_file, it gets
# exported as FOO='', this is obviously problematic if you want things
# to use default values if not assigned.
# So instead we add it to -e FOO=${default_in_file:-${shell_value}
if [ -f "${env_file}" ]; then
# Slurp environment variables from shell that exist in env_file
for e in $(cut -d '=' -f 1 < ${env_file} | grep -v '^#'); do
if [ ! -z ${!e+x} ]; then
additional_envs_args+=" -e ${e}"
else
v=$(grep "^${e}=" ${env_file} | cut -d '=' -f 2)
if [ -n "${v}" ]; then
additional_envs_args+=" -e ${e}=\"${v}\""
fi
fi
done
fi
docker run --rm \
-u $(id -u):$(id -g) \
-v ${PWD}:/workspace \
${HASHICORP_HELPER_EXTRA_OPTS} \
${additional_envs_args} \
${env_file_args} \
nodeintegration/hashicorp-tools:${HASHICORP_HELPER_TAG} \
${@}
}
function terraform() {
hashicorp-helper terraform ${@}
}
function packer() {
hashicorp-helper packer ${@}
}
function consul() {
hashicorp-helper consul ${@}
}
function vault() {
hashicorp-helper vault ${@}
}
function nomad() {
hashicorp-helper nomad ${@}
}