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 cee2b18
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 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
28 changes: 17 additions & 11 deletions scripts/commands/helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ 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
set +f # Enable globbing
for file in "${decrypted_file_list_dir}"/*.file; do
set -f # Disable globbing

if [ -e "$file" ]; then # Make sure it isn't an empty match, in case of no files
decrypted_file=$(cat "$file")
rm -- "$(printf '%s' "$decrypted_file")"

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

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

Expand Down Expand Up @@ -209,7 +215,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}.file"

if [ "${QUIET}" = "false" ]; then
log 'Decrypt: %s' "${file}"
Expand Down

0 comments on commit cee2b18

Please sign in to comment.