Skip to content

Commit

Permalink
remove dependency on xargs
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Oct 11, 2024
1 parent b5a3b6b commit f89d015
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.6.2] - 2024-10-12

### Fixes
- fix: examples in the help of encrypt/decrypt commands
- fix: remove dependency on `xargs`, since it's not available on OpenShift

## [4.6.1] - 2024-08-09

Expand Down Expand Up @@ -328,7 +331,8 @@ Started a fork of https://github.com/zendesk/helm-secrets
- Verbose output is now on stderr
- Support all helm sub commands and plugins

[Unreleased]: https://github.com/kroepke/helm-secrets/compare/v4.6.1...HEAD
[Unreleased]: https://github.com/kroepke/helm-secrets/compare/v4.6.2...HEAD
[4.6.2]: https://github.com/jkroepke/helm-secrets/compare/v4.6.1...v4.6.2
[4.6.1]: https://github.com/jkroepke/helm-secrets/compare/v4.6.0...v4.6.1
[4.6.0]: https://github.com/jkroepke/helm-secrets/compare/v4.5.1...v4.6.0
[4.5.1]: https://github.com/jkroepke/helm-secrets/compare/v4.5.0...v4.5.1
Expand Down
24 changes: 13 additions & 11 deletions scripts/commands/helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ Typical usage:
EOF
}

decrypted_file_list=$(_mktemp)
decrypted_file_list_dir=$(_mktemp -d)

_trap_hook() {
if [ -s "${decrypted_file_list}" ]; then
if [ "${QUIET}" = "false" ]; then
echo >&2
# shellcheck disable=SC2016
xargs -0 -n1 sh -c 'rm "$1" && printf "[helm-secrets] Removed: %s\n" "$1"' sh >&2 <"${decrypted_file_list}"
else
xargs -0 rm >&2 <"${decrypted_file_list}"
fi
if [ -d "${decrypted_file_list_dir}" ]; then
for file in "${decrypted_file_list_dir}"/*; do
if [ -e "$file" ]; then # Make sure it isn't an empty match, in case of no files
rm -- "$(printf '%s' "$file")"

if [ "${QUIET}" = "false" ]; then
printf "[helm-secrets] Removed: %s\n" "$file"
fi
fi
done

rm "${decrypted_file_list}"
rm -rf "${decrypted_file_list_dir}"
fi
}

Expand Down Expand Up @@ -209,7 +211,7 @@ helm_wrapper() {
fi
else
if decrypt_helper "${real_file}" "${sops_type}"; then
printf '%s\0' "${file_dec}" >>"${decrypted_file_list}"
printf '%s' "${file_dec}" >"${decrypted_file_list_dir}/${j}"

if [ "${QUIET}" = "false" ]; then
log 'Decrypt: %s' "${file}"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/template.bats
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ load '../bats/extensions/bats-file/load'

create_chart "${TEST_TEMP_DIR}"

run "${HELM_BIN}" secrets template "${TEST_TEMP_DIR}/chart" -f "${VALUES_PATH}" 2>&1
run "${HELM_BIN}" --debug secrets template "${TEST_TEMP_DIR}/chart" -f "${VALUES_PATH}" 2>&1

assert_output -e "\[helm-secrets\] Decrypt: .*${VALUES}"
assert_output --partial "port: 81"
Expand Down

0 comments on commit f89d015

Please sign in to comment.