From 3b9cae9c510184e1201f58d67b122b2a5fed8df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Thu, 14 Sep 2023 20:58:06 +0200 Subject: [PATCH 1/2] fix multiline commands --- scripts/commands/helm.sh | 18 +++++++++++++++--- tests/unit/template.bats | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/scripts/commands/helm.sh b/scripts/commands/helm.sh index d60b4e9f..91b581bc 100644 --- a/scripts/commands/helm.sh +++ b/scripts/commands/helm.sh @@ -66,12 +66,24 @@ helm_wrapper() { decrypted_literals="" - IFS=' -' + IFS="," + _literal="" - for literal in $(printf '%s' "${literals}" | sed -E 's/([^\\]),/\1\n/g'); do + for literal in ${literals}; do unset IFS + case "${literal}" in + *\\) + _literal="${literal}" + continue + ;; + esac + + if [ "${_literal}" != "" ]; then + literal="${_literal},${literal}" + _literal="" + fi + opt_prefix="${literal%%=*}=" literal="${literal#*=}" diff --git a/tests/unit/template.bats b/tests/unit/template.bats index 5e980ced..0c031ecb 100755 --- a/tests/unit/template.bats +++ b/tests/unit/template.bats @@ -169,6 +169,24 @@ load '../bats/extensions/bats-file/load' assert_file_not_exists "${VALUES_PATH}.dec" } +@test "template: helm template w/ chart + secrets.yaml + helm flag + multiline" { + VALUES="assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml" + VALUES_PATH="${TEST_TEMP_DIR}/${VALUES}" + + create_chart "${TEST_TEMP_DIR}" + + run "${HELM_BIN}" secrets template "${TEST_TEMP_DIR}/chart" -f "${VALUES_PATH}" --set "podAnnotations.second=key1: +key2: value" 2>&1 + + assert_output -e "\[helm-secrets\] Decrypt: .*${VALUES}" + assert_output --partial "port: 81" + assert_output --partial "key1:" + assert_output --partial "key2: value" + assert_output -e "\[helm-secrets\] Removed: .*${VALUES}.dec" + assert_success + assert_file_not_exists "${VALUES_PATH}.dec" +} + @test "template: helm template w/ chart + not-exists.yaml" { VALUES="not-exists.yaml" VALUES_PATH="${VALUES}" From 75018894d21f5217251c2c82589fc831c57ebe9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Thu, 14 Sep 2023 21:56:18 +0200 Subject: [PATCH 2/2] fix multiline commands --- CHANGELOG.md | 5 ++++- tests/unit/template.bats | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef8b72c..c314f272 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- `secrets+*-import://` added syntax checks +- `secrets+*-import://` added syntax checks + +### Fixed +- Multiline parameter values ## [4.5.0] - 2023-08-14 diff --git a/tests/unit/template.bats b/tests/unit/template.bats index 0c031ecb..0ebca5c7 100755 --- a/tests/unit/template.bats +++ b/tests/unit/template.bats @@ -170,6 +170,10 @@ load '../bats/extensions/bats-file/load' } @test "template: helm template w/ chart + secrets.yaml + helm flag + multiline" { + if on_windows; then + skip + fi + VALUES="assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml" VALUES_PATH="${TEST_TEMP_DIR}/${VALUES}"