Skip to content

Commit

Permalink
Merge pull request #405 from jkroepke/fix-multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke authored Sep 14, 2023
2 parents 821ca3f + 7501889 commit 07b89b1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 15 additions & 3 deletions scripts/commands/helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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#*=}"

Expand Down
22 changes: 22 additions & 0 deletions tests/unit/template.bats
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,28 @@ load '../bats/extensions/bats-file/load'
assert_file_not_exists "${VALUES_PATH}.dec"
}

@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}"

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}"
Expand Down

0 comments on commit 07b89b1

Please sign in to comment.