@@ -45,10 +45,9 @@ if [[ -n "${secret_prefix}" && ! "${secret_prefix}" =~ /$ ]]; then
45
45
fi
46
46
readonly secret_prefix
47
47
48
+ # Resolve secrets
48
49
# #######################################################################
49
50
50
- readonly container_name=" vault-env-plugin-${BUILDKITE_JOB_ID} "
51
-
52
51
# STOLEN FROM https://github.com/buildkite-plugins/docker-buildkite-plugin/blob/9f90d8ef742d9fa1eb3556720e16f2b842ff1cb2/hooks/command#L25-L47
53
52
#
54
53
# Reads a list from plugin config into a global result array
@@ -74,14 +73,22 @@ plugin_read_list_into_result() {
74
73
[[ ${# result[@]} -gt 0 ]] || return 1
75
74
}
76
75
77
- envconsul_env () {
78
- # This populates a `result` array for later use
79
- plugin_read_list_into_result BUILDKITE_PLUGIN_VAULT_ENV_SECRETS
76
+ secrets=()
77
+ if plugin_read_list_into_result BUILDKITE_PLUGIN_VAULT_ENV_SECRETS; then
78
+ secrets=(" ${result[@]} " )
79
+ else
80
+ raise_error " At least one secret must be specified!"
81
+ fi
80
82
81
- secrets=()
82
- for secret in " ${result[@]} " ; do
83
+ # #######################################################################
84
+
85
+ readonly container_name=" vault-env-plugin-${BUILDKITE_JOB_ID} "
86
+
87
+ envconsul_env () {
88
+ args=()
89
+ for secret in " ${secrets[@]} " ; do
83
90
# secret_prefix is guaranteed to end with a / if it is non-empty
84
- secrets +=(" -secret=${secret_prefix}${secret} " )
91
+ args +=(" -secret=${secret_prefix}${secret} " )
85
92
done
86
93
87
94
# Explicitly *not* using `--rm` so we can output the container
@@ -91,7 +98,7 @@ envconsul_env() {
91
98
--name=" ${container_name} " \
92
99
-- \
93
100
" ${image} " \
94
- " ${secrets [@]} " \
101
+ " ${args [@]} " \
95
102
-once \
96
103
-upcase \
97
104
-pristine \
0 commit comments