diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-12-15 00:41:51 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-12-18 18:04:54 +1300 |
commit | dd3668adefa1b65e0fb58df33350b5ed144f5c44 (patch) | |
tree | 7e8ac71500a382fb0778fbab0e1ff6b7d3315a9b | |
parent | ef2407475414d9d96d174777b83053a75a05630f (diff) | |
download | gitlab-ce-dd3668adefa1b65e0fb58df33350b5ed144f5c44.tar.gz |
Minor edits based on BE feedback
-rw-r--r-- | lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml index ad1c6f2bf92..1b55a6b12cd 100644 --- a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml @@ -595,12 +595,13 @@ rollout 100%: fi } - # "Returns" any prefixed variables with - # the global variable $K8S_VARIABLES - function get_prefixed_variables() { - prefix="K8S_SECRET" + # Finds any variables prefixed with `K8S_SECRET_`, and exports them as the + # global $K8S_VARIABLES with prefix removed. + function extract_prefixed_variables() { + prefix="K8S_SECRET_" + k8s_variables=$(env | (grep "^${prefix}" || [[ $? == 1 ]]) | sed "s/^${prefix}//") - export K8S_VARIABLES=$(env | (grep "^${prefix}_" || [[ $? == 1 ]]) | sed "s/^${prefix}_//") + export K8S_VARIABLES=$k8s_variables } function deploy() { @@ -628,14 +629,14 @@ rollout 100%: secret_name='' fi - get_prefixed_variables + extract_prefixed_variables if [[ -n "$K8S_VARIABLES" ]]; then echo "Prefixed CI variables found, creating secret..." application_secret_name="${name}-secret" - fromLiteralArgs="" - for var in ${K8S_VARIABLES}; do - fromLiteralArgs="${fromLiteralArgs:+${fromLiteralArgs} }--from-literal=${var}" + + for k8s_variable in ${K8S_VARIABLES}; do + fromLiteralArgs="${fromLiteralArgs:+${fromLiteralArgs} }--from-literal=${k8s_variable}" done # We want fromLiteralArgs to be interpreted as args, so don't quote it! |