Skip to content

Commit 7377c18

Browse files
committed
CI: Allow passing environment to test containers
Signed-off-by: mdouglas47 <mdouglas47@bloomberg.net>
1 parent 5f549a2 commit 7377c18

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/docker/runit

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44
nodeprefix="m"
55

66
script_args=()
7+
env_vars=()
78
while [[ $1 = -* ]]; do
89
if [[ "$1" = "-s" ]] || [[ "$1" = "--source" ]]; then
910
shift
@@ -23,6 +24,9 @@ while [[ $1 = -* ]]; do
2324
elif [[ "$1" = "-a" ]] || [[ "$1" = "--file-arg" ]]; then
2425
shift
2526
script_args+=("$1")
27+
elif [[ "$1" = "-e" ]] || [[ "$1" = "--env" ]]; then
28+
shift
29+
env_vars+=("$1") # expect VAR=VALUE
2630
fi
2731
shift
2832
done
@@ -73,6 +77,20 @@ echo $cluster >common/cluster
7377
ssh-keygen -N "" -f common/id_rsa
7478

7579
compose=docker-compose.yml
80+
81+
append_env_to_compose() {
82+
if ((${#env_vars[@]} > 0)); then
83+
cat >> $compose <<EOF
84+
environment:
85+
EOF
86+
for e in "${env_vars[@]}"; do
87+
cat >> $compose <<EOF
88+
- ${e}
89+
EOF
90+
done
91+
fi
92+
}
93+
7694
cat > $compose <<EOF
7795
version: '2'
7896
@@ -104,6 +122,8 @@ EOF
104122
EOF
105123
}
106124

125+
append_env_to_compose
126+
107127
cat >> $compose <<EOF
108128
command: /client $commands
109129
cap_add:
@@ -140,6 +160,9 @@ EOF
140160
EOF
141161

142162
}
163+
164+
append_env_to_compose
165+
143166
cat >> $compose <<EOF
144167
command: /server
145168
cap_add:

0 commit comments

Comments
 (0)