Last active
December 19, 2025 14:31
-
-
Save aslafy-z/8143562364b4932b99400b355713d6c2 to your computer and use it in GitHub Desktop.
kustomize helm wrapper for downloader plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # kustomize-helm-plugin-wrapper: force Helm to see the helm plugins even when kustomize sets HELM_*_HOME to temp dirs. | |
| # | |
| # Usage: | |
| # chmod +x ./kustomize-helm-plugin-wrapper | |
| # kustomize build --enable-helm --helm-command ./kustomize-helm-plugin-wrapper . | |
| # # or: kubectl kustomize --enable-helm --helm-command ./kustomize-helm-plugin-wrapper . | |
| # | |
| # Optional: | |
| # HELM_REAL_BIN=/usr/bin/helm ./kustomize-helm-plugin-wrapper version | |
| set -eu | |
| # Avoid recursion if someone names this script "helm" | |
| REAL_HELM="${HEM_REAL_BIN:-${HELM_REAL_BIN:-}}" | |
| if [ -z "${REAL_HELM:-}" ]; then | |
| REAL_HELM="$(command -v helm || true)" | |
| fi | |
| if [ -z "${REAL_HELM:-}" ] || [ ! -x "${REAL_HELM:-/nonexistent}" ]; then | |
| echo "kustomize-helm-plugin-wrapper: could not find real 'helm' binary. Set HELM_REAL_BIN=/path/to/helm" >&2 | |
| exit 127 | |
| fi | |
| # If HELM_PLUGINS is already set, honor it. | |
| if [ -z "${HELM_PLUGINS:-}" ]; then | |
| # Try common plugin locations (Linux/macOS; root and non-root). | |
| for d in \ | |
| "$HOME/.local/share/helm/plugins" \ | |
| "$HOME/.helm/plugins" \ | |
| "/root/.local/share/helm/plugins" \ | |
| "/usr/local/share/helm/plugins" \ | |
| "/usr/share/helm/plugins" | |
| do | |
| if [ -d "$d" ]; then | |
| HELM_PLUGINS="$d" | |
| break | |
| fi | |
| done | |
| fi | |
| if [ -z "${HELM_PLUGINS:-}" ] || [ ! -d "${HELM_PLUGINS}" ]; then | |
| echo "kustomize-helm-plugin-wrapper: HELM_PLUGINS is not set and no default plugin dir exists." >&2 | |
| echo "kustomize-helm-plugin-wrapper: set HELM_PLUGINS to the directory containing your Helm plugins." >&2 | |
| echo "kustomize-helm-plugin-wrapper: example: export HELM_PLUGINS=\$HOME/.local/share/helm/plugins" >&2 | |
| exit 1 | |
| fi | |
| # Export so helm can find plugins regardless of HELM_DATA_HOME/HELM_CONFIG_HOME set by kustomize. | |
| export HELM_PLUGINS | |
| exec "$REAL_HELM" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment