Skip to content

Commit

Permalink
remove dependency on xargs (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke authored Oct 13, 2024
1 parent a5c4bd4 commit ff97775
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ jobs:
fi
echo -e '[epel]\nname=Extra Packages for Enterprise Linux $releasever - $basearch\nmetalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir\nenabled=1\ngpgcheck=1\ngpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8' > /etc/yum.repos.d/epel.repo
microdnf install --nodocs git-core unzip tar findutils diffutils parallel
# remove xargs from RHEL image to keep compatibility with OpenShift GitOps
rm -f "$(which xargs)"
fi
- name: Install zsh
Expand Down
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-13

### 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" >&2
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 ff97775

Please sign in to comment.