From 28e4cf4201ce88befb5fe4f70fd7c6521f58acdb Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Thu, 26 Mar 2026 11:46:29 -0500 Subject: [PATCH 1/8] adding airgap install instructions --- README.md | 7 +++++++ install-binary.ps1 | 38 +++++++++++++++++++++-------------- install-binary.sh | 49 ++++++++++++++++++++++++++++------------------ 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 42d831f9..4bb8eb5e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,13 @@ This can also be used to compare two revisions/versions of your helm release. helm plugin install https://github.com/databus23/helm-diff ``` +### Installing offline +If installing this in an offline/airgapped environment, download the bin .tgz from [releases](https://github.com/databus23/helm-diff/releases). Set $HELM_DIFF_BIN_TGZ to the absolute path to the bin .tgz. + +Now, run `helm plugin install /path/to/helm-diff/`. + +The install script will skip the github download and instead install from the .tgz. + **For Helm 4 users:** Helm 4 requires plugin verification by default. Since this plugin does not yet provide provenance artifacts, you need to use the `--verify=false` flag: diff --git a/install-binary.ps1 b/install-binary.ps1 index e182b4c3..899b4498 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -4,27 +4,22 @@ param ( function Get-Architecture { $architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture - $arch = switch ($architecture) { - "X64" { "amd64" } + "X64" { "amd64" } "Arm64" { "arm64" } Default { "" } } - if ($arch -eq "") { throw "Unsupported architecture: ${architecture}" } - return $arch } function Get-Version { param ([Parameter(Mandatory=$true)][bool] $Update) - if ($Update) { return "latest" } - return git describe --tags --exact-match 2>$null || "latest" } @@ -37,7 +32,6 @@ function New-TemporaryDirectory { function Get-Url { param ([Parameter(Mandatory=$true)][string] $Version, [Parameter(Mandatory=$true)][string] $Architecture) - if ($Version -eq "latest") { return "https://github.com/databus23/helm-diff/releases/latest/download/helm-diff-windows-${Architecture}.tgz" } @@ -46,32 +40,46 @@ function Get-Url { function Download-Plugin { param ([Parameter(Mandatory=$true)][string] $Url, [Parameter(Mandatory=$true)][string] $Output) - Invoke-WebRequest -OutFile $Output $Url } function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) - Push-Location $ArchiveDirectory tar -xzf $ArchiveName -C . Pop-Location - New-Item -ItemType Directory -Path $Destination -Force Copy-Item -Path (Join-Path $ArchiveDirectory "diff" "bin" "diff.exe") -Destination $Destination -Force } $ErrorActionPreference = "Stop" - $archiveName = "helm-diff.tgz" $arch = Get-Architecture $version = Get-Version -Update $Update $tmpDir = New-TemporaryDirectory - trap { Remove-Item -path $tmpDir -Recurse -Force } -$url = Get-Url -Version $version -Architecture $arch +# --- MODIFICATION START --- + $output = Join-Path $tmpDir $archiveName -Download-Plugin -Url $url -Output $output -Install-Plugin -ArchiveDirectory $tmpDir -ArchiveName $archiveName -Destination (Join-Path $env:HELM_PLUGIN_DIR "bin") \ No newline at end of file +# Check for offline installation via environment variable +if ($env:HELM_DIFF_BIN_TGZ) { + Write-Host "HELM_DIFF_BIN_TGZ is set. Using local package at: $($env:HELM_DIFF_BIN_TGZ)" + + if (-not (Test-Path $env:HELM_DIFF_BIN_TGZ -PathType Leaf)) { + throw "Offline installation failed: File not found at '$($env:HELM_DIFF_BIN_TGZ)'" + } + Copy-Item -Path $env:HELM_DIFF_BIN_TGZ -Destination $output +} +else { + # Proceed with online installation + Write-Host "HELM_DIFF_BIN_TGZ not set. Proceeding with online installation." + $url = Get-Url -Version $version -Architecture $arch + Download-Plugin -Url $url -Output $output +} + +# --- MODIFICATION END --- + +Install-Plugin -ArchiveDirectory $tmpDir -ArchiveName $archiveName -Destination (Join-Path $env:HELM_PLUGIN_DIR "bin") + diff --git a/install-binary.sh b/install-binary.sh index da8782e9..e108baba 100755 --- a/install-binary.sh +++ b/install-binary.sh @@ -10,18 +10,14 @@ export GREP_COLOR="never" # available. This is the case when using MSYS2 or Cygwin # on Windows where helm returns a Windows path but we # need a Unix path - if command -v cygpath >/dev/null 2>&1; then HELM_BIN="$(cygpath -u "${HELM_BIN}")" HELM_PLUGIN_DIR="$(cygpath -u "${HELM_PLUGIN_DIR}")" fi [ -z "$HELM_BIN" ] && HELM_BIN=$(command -v helm) - [ -z "$HELM_HOME" ] && HELM_HOME=$(helm env | grep 'HELM_DATA_HOME' | cut -d '=' -f2 | tr -d '"') - mkdir -p "$HELM_HOME" - : "${HELM_PLUGIN_DIR:="$HELM_HOME/plugins/helm-diff"}" if [ "$SKIP_BIN_INSTALL" = "1" ]; then @@ -55,7 +51,6 @@ initArch() { # initOS discovers the operating system for this system. initOS() { OS=$(uname -s) - case "$OS" in Windows_NT) OS='windows' ;; # Msys support @@ -77,16 +72,21 @@ verifySupported() { exit 1 fi - if - ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1 - then - echo "Either curl or wget is required" - exit 1 + # Skip download tool check if using local file + if [ -z "$HELM_DIFF_BIN_TGZ" ]; then + if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then + echo "Either curl or wget is required" + exit 1 + fi fi } # getDownloadURL checks the latest available version. getDownloadURL() { + # If HELM_DIFF_BIN_TGZ is set, we don't need a download URL + if [ -n "$HELM_DIFF_BIN_TGZ" ]; then + return + fi version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :) if [ "$SCRIPT_MODE" = "install" ] && [ -n "$version" ]; then DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/helm-diff-$OS-$ARCH.tgz" @@ -99,6 +99,7 @@ getDownloadURL() { mkTempDir() { HELM_TMP="$(mktemp -d -t "${PROJECT_NAME}-XXXXXX")" } + rmTempDir() { if [ -d "${HELM_TMP:-/tmp/helm-diff-tmp}" ]; then rm -rf "${HELM_TMP:-/tmp/helm-diff-tmp}" @@ -109,14 +110,22 @@ rmTempDir() { # for that binary. downloadFile() { PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" + + # If HELM_DIFF_BIN_TGZ is set, copy the local file instead of downloading + if [ -n "$HELM_DIFF_BIN_TGZ" ]; then + echo "Using local package at $HELM_DIFF_BIN_TGZ" + if [ ! -f "$HELM_DIFF_BIN_TGZ" ]; then + echo "Error: file not found at $HELM_DIFF_BIN_TGZ" + exit 1 + fi + cp "$HELM_DIFF_BIN_TGZ" "$PLUGIN_TMP_FILE" + return + fi + echo "Downloading $DOWNLOAD_URL" - if - command -v curl >/dev/null 2>&1 - then + if command -v curl >/dev/null 2>&1; then curl -sSf -L "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" - elif - command -v wget >/dev/null 2>&1 - then + elif command -v wget >/dev/null 2>&1; then wget -q -O - "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" fi } @@ -124,6 +133,7 @@ downloadFile() { # installFile verifies the SHA256 for the file, then unpacks and # installs it. installFile() { + PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" tar xzf "$PLUGIN_TMP_FILE" -C "$HELM_TMP" HELM_TMP_BIN="$HELM_TMP/diff/bin/diff" if [ "${OS}" = "windows" ]; then @@ -145,11 +155,11 @@ exit_trap() { exit $result } -# Execution - -#Stop execution on any error +# --- Execution --- +# Stop execution on any error trap "exit_trap" EXIT set -e + initArch initOS verifySupported @@ -157,3 +167,4 @@ getDownloadURL mkTempDir downloadFile installFile + From 387dc7a2d39a4784aa0f468ffa9c0bf57e7f7081 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Thu, 26 Mar 2026 11:52:43 -0500 Subject: [PATCH 2/8] remove extraneous lines --- install-binary.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 899b4498..6f18f409 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -59,8 +59,6 @@ $version = Get-Version -Update $Update $tmpDir = New-TemporaryDirectory trap { Remove-Item -path $tmpDir -Recurse -Force } -# --- MODIFICATION START --- - $output = Join-Path $tmpDir $archiveName # Check for offline installation via environment variable @@ -79,7 +77,5 @@ else { Download-Plugin -Url $url -Output $output } -# --- MODIFICATION END --- - Install-Plugin -ArchiveDirectory $tmpDir -ArchiveName $archiveName -Destination (Join-Path $env:HELM_PLUGIN_DIR "bin") From 64005a2487a1e5a43b3bc1e50832ceb2a022a37c Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sat, 28 Mar 2026 08:20:53 -0500 Subject: [PATCH 3/8] remove extraneous comments that did not apply to final code, applied shell script formatting --- install-binary.sh | 186 +++++++++++++++++++++++----------------------- 1 file changed, 92 insertions(+), 94 deletions(-) diff --git a/install-binary.sh b/install-binary.sh index e108baba..4db3818b 100755 --- a/install-binary.sh +++ b/install-binary.sh @@ -11,8 +11,8 @@ export GREP_COLOR="never" # on Windows where helm returns a Windows path but we # need a Unix path if command -v cygpath >/dev/null 2>&1; then - HELM_BIN="$(cygpath -u "${HELM_BIN}")" - HELM_PLUGIN_DIR="$(cygpath -u "${HELM_PLUGIN_DIR}")" + HELM_BIN="$(cygpath -u "${HELM_BIN}")" + HELM_PLUGIN_DIR="$(cygpath -u "${HELM_PLUGIN_DIR}")" fi [ -z "$HELM_BIN" ] && HELM_BIN=$(command -v helm) @@ -21,138 +21,137 @@ mkdir -p "$HELM_HOME" : "${HELM_PLUGIN_DIR:="$HELM_HOME/plugins/helm-diff"}" if [ "$SKIP_BIN_INSTALL" = "1" ]; then - echo "Skipping binary install" - exit + echo "Skipping binary install" + exit fi # which mode is the common installer script running in SCRIPT_MODE="install" if [ "$1" = "-u" ]; then - SCRIPT_MODE="update" + SCRIPT_MODE="update" fi # initArch discovers the architecture for this system. initArch() { - ARCH=$(uname -m) - case $ARCH in - armv5*) ARCH="armv5" ;; - armv6*) ARCH="armv6" ;; - armv7*) ARCH="armv7" ;; - aarch64) ARCH="arm64" ;; - x86) ARCH="386" ;; - x86_64) ARCH="amd64" ;; - i686) ARCH="386" ;; - i386) ARCH="386" ;; - ppc64le) ARCH="ppc64le" ;; - s390x) ARCH="s390x" ;; - esac + ARCH=$(uname -m) + case $ARCH in + armv5*) ARCH="armv5" ;; + armv6*) ARCH="armv6" ;; + armv7*) ARCH="armv7" ;; + aarch64) ARCH="arm64" ;; + x86) ARCH="386" ;; + x86_64) ARCH="amd64" ;; + i686) ARCH="386" ;; + i386) ARCH="386" ;; + ppc64le) ARCH="ppc64le" ;; + s390x) ARCH="s390x" ;; + esac } # initOS discovers the operating system for this system. initOS() { - OS=$(uname -s) - case "$OS" in - Windows_NT) OS='windows' ;; - # Msys support - MSYS*) OS='windows' ;; - # Minimalist GNU for Windows - MINGW*) OS='windows' ;; - CYGWIN*) OS='windows' ;; - Darwin) OS='macos' ;; - Linux) OS='linux' ;; - esac + OS=$(uname -s) + case "$OS" in + Windows_NT) OS='windows' ;; + # Msys support + MSYS*) OS='windows' ;; + # Minimalist GNU for Windows + MINGW*) OS='windows' ;; + CYGWIN*) OS='windows' ;; + Darwin) OS='macos' ;; + Linux) OS='linux' ;; + esac } # verifySupported checks that the os/arch combination is supported for # binary builds. verifySupported() { - supported="linux-amd64\nlinux-arm64\nlinux-armv6\nlinux-armv7\nlinux-ppc64le\nlinux-s390x\nfreebsd-amd64\nfreebsd-arm64\nmacos-amd64\nmacos-arm64\nwindows-amd64\nwindows-arm64" - if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then - echo "No prebuild binary for ${OS}-${ARCH}." - exit 1 - fi - - # Skip download tool check if using local file - if [ -z "$HELM_DIFF_BIN_TGZ" ]; then - if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then - echo "Either curl or wget is required" - exit 1 - fi - fi + supported="linux-amd64\nlinux-arm64\nlinux-armv6\nlinux-armv7\nlinux-ppc64le\nlinux-s390x\nfreebsd-amd64\nfreebsd-arm64\nmacos-amd64\nmacos-arm64\nwindows-amd64\nwindows-arm64" + if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then + echo "No prebuild binary for ${OS}-${ARCH}." + exit 1 + fi + + # Skip download tool check if using local file + if [ -z "$HELM_DIFF_BIN_TGZ" ]; then + if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then + echo "Either curl or wget is required" + exit 1 + fi + fi } # getDownloadURL checks the latest available version. getDownloadURL() { - # If HELM_DIFF_BIN_TGZ is set, we don't need a download URL - if [ -n "$HELM_DIFF_BIN_TGZ" ]; then - return - fi - version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :) - if [ "$SCRIPT_MODE" = "install" ] && [ -n "$version" ]; then - DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/helm-diff-$OS-$ARCH.tgz" - else - DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/latest/download/helm-diff-$OS-$ARCH.tgz" - fi + # If HELM_DIFF_BIN_TGZ is set, we don't need a download URL + if [ -n "$HELM_DIFF_BIN_TGZ" ]; then + return + fi + version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :) + if [ "$SCRIPT_MODE" = "install" ] && [ -n "$version" ]; then + DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/helm-diff-$OS-$ARCH.tgz" + else + DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/latest/download/helm-diff-$OS-$ARCH.tgz" + fi } # Temporary dir mkTempDir() { - HELM_TMP="$(mktemp -d -t "${PROJECT_NAME}-XXXXXX")" + HELM_TMP="$(mktemp -d -t "${PROJECT_NAME}-XXXXXX")" } rmTempDir() { - if [ -d "${HELM_TMP:-/tmp/helm-diff-tmp}" ]; then - rm -rf "${HELM_TMP:-/tmp/helm-diff-tmp}" - fi + if [ -d "${HELM_TMP:-/tmp/helm-diff-tmp}" ]; then + rm -rf "${HELM_TMP:-/tmp/helm-diff-tmp}" + fi } # downloadFile downloads the latest binary package and also the checksum # for that binary. downloadFile() { - PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" - - # If HELM_DIFF_BIN_TGZ is set, copy the local file instead of downloading - if [ -n "$HELM_DIFF_BIN_TGZ" ]; then - echo "Using local package at $HELM_DIFF_BIN_TGZ" - if [ ! -f "$HELM_DIFF_BIN_TGZ" ]; then - echo "Error: file not found at $HELM_DIFF_BIN_TGZ" - exit 1 - fi - cp "$HELM_DIFF_BIN_TGZ" "$PLUGIN_TMP_FILE" - return - fi - - echo "Downloading $DOWNLOAD_URL" - if command -v curl >/dev/null 2>&1; then - curl -sSf -L "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" - elif command -v wget >/dev/null 2>&1; then - wget -q -O - "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" - fi + PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" + + # If HELM_DIFF_BIN_TGZ is set, copy the local file instead of downloading + if [ -n "$HELM_DIFF_BIN_TGZ" ]; then + echo "Using local package at $HELM_DIFF_BIN_TGZ" + if [ ! -f "$HELM_DIFF_BIN_TGZ" ]; then + echo "Error: file not found at $HELM_DIFF_BIN_TGZ" + exit 1 + fi + cp "$HELM_DIFF_BIN_TGZ" "$PLUGIN_TMP_FILE" + return + fi + + echo "Downloading $DOWNLOAD_URL" + if command -v curl >/dev/null 2>&1; then + curl -sSf -L "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" + elif command -v wget >/dev/null 2>&1; then + wget -q -O - "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" + fi } -# installFile verifies the SHA256 for the file, then unpacks and -# installs it. +# Unpack the archive file, then install it into the helm directory. installFile() { - PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" - tar xzf "$PLUGIN_TMP_FILE" -C "$HELM_TMP" - HELM_TMP_BIN="$HELM_TMP/diff/bin/diff" - if [ "${OS}" = "windows" ]; then - HELM_TMP_BIN="$HELM_TMP_BIN.exe" - fi - echo "Preparing to install into ${HELM_PLUGIN_DIR}" - mkdir -p "$HELM_PLUGIN_DIR/bin" - cp "$HELM_TMP_BIN" "$HELM_PLUGIN_DIR/bin" + PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" + tar xzf "$PLUGIN_TMP_FILE" -C "$HELM_TMP" + HELM_TMP_BIN="$HELM_TMP/diff/bin/diff" + if [ "${OS}" = "windows" ]; then + HELM_TMP_BIN="$HELM_TMP_BIN.exe" + fi + echo "Preparing to install into ${HELM_PLUGIN_DIR}" + mkdir -p "$HELM_PLUGIN_DIR/bin" + cp "$HELM_TMP_BIN" "$HELM_PLUGIN_DIR/bin" } # exit_trap is executed if on exit (error or not). exit_trap() { - result=$? - rmTempDir - if [ "$result" != "0" ]; then - echo "Failed to install $PROJECT_NAME" - printf '\tFor support, go to https://github.com/databus23/helm-diff.\n' - fi - exit $result + result=$? + rmTempDir + if [ "$result" != "0" ]; then + echo "Failed to install $PROJECT_NAME" + printf '\tFor support, go to https://github.com/databus23/helm-diff.\n' + fi + exit $result } # --- Execution --- @@ -167,4 +166,3 @@ getDownloadURL mkTempDir downloadFile installFile - From 4339efa71dfbb474cfc334d34102301a1883e16c Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sat, 28 Mar 2026 08:25:45 -0500 Subject: [PATCH 4/8] update readme to add concrete examples and follow syntax and formatting of the rest of the document --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4bb8eb5e..c87c128c 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,20 @@ helm plugin install https://github.com/databus23/helm-diff ``` ### Installing offline -If installing this in an offline/airgapped environment, download the bin .tgz from [releases](https://github.com/databus23/helm-diff/releases). Set $HELM_DIFF_BIN_TGZ to the absolute path to the bin .tgz. +If installing this in an offline/airgapped environment, download the bin `.tgz` from [releases](https://github.com/databus23/helm-diff/releases). Set `HELM_DIFF_BIN_TGZ` to the absolute path to the bin `.tgz`: -Now, run `helm plugin install /path/to/helm-diff/`. +**POSIX shell:** +```sh +export HELM_DIFF_BIN_TGZ=/path/to/helm-diff-bin.tgz +``` + +**PowerShell:** +```powershell +$env:HELM_DIFF_BIN_TGZ = "C:\path\to\helm-diff-bin.tgz" +``` -The install script will skip the github download and instead install from the .tgz. +Now, run `helm plugin install /path/to/helm-diff/`. +The install script will skip the GitHub download and instead install from the `.tgz`. **For Helm 4 users:** From 0dc6967f9d157f810db970fc27b38c6576762ede Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Sat, 28 Mar 2026 08:28:49 -0500 Subject: [PATCH 5/8] running shfmt -w on bash script/ --- install-binary.sh | 182 +++++++++++++++++++++++----------------------- 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/install-binary.sh b/install-binary.sh index 4db3818b..3cbbc6e4 100755 --- a/install-binary.sh +++ b/install-binary.sh @@ -11,8 +11,8 @@ export GREP_COLOR="never" # on Windows where helm returns a Windows path but we # need a Unix path if command -v cygpath >/dev/null 2>&1; then - HELM_BIN="$(cygpath -u "${HELM_BIN}")" - HELM_PLUGIN_DIR="$(cygpath -u "${HELM_PLUGIN_DIR}")" + HELM_BIN="$(cygpath -u "${HELM_BIN}")" + HELM_PLUGIN_DIR="$(cygpath -u "${HELM_PLUGIN_DIR}")" fi [ -z "$HELM_BIN" ] && HELM_BIN=$(command -v helm) @@ -21,137 +21,137 @@ mkdir -p "$HELM_HOME" : "${HELM_PLUGIN_DIR:="$HELM_HOME/plugins/helm-diff"}" if [ "$SKIP_BIN_INSTALL" = "1" ]; then - echo "Skipping binary install" - exit + echo "Skipping binary install" + exit fi # which mode is the common installer script running in SCRIPT_MODE="install" if [ "$1" = "-u" ]; then - SCRIPT_MODE="update" + SCRIPT_MODE="update" fi # initArch discovers the architecture for this system. initArch() { - ARCH=$(uname -m) - case $ARCH in - armv5*) ARCH="armv5" ;; - armv6*) ARCH="armv6" ;; - armv7*) ARCH="armv7" ;; - aarch64) ARCH="arm64" ;; - x86) ARCH="386" ;; - x86_64) ARCH="amd64" ;; - i686) ARCH="386" ;; - i386) ARCH="386" ;; - ppc64le) ARCH="ppc64le" ;; - s390x) ARCH="s390x" ;; - esac + ARCH=$(uname -m) + case $ARCH in + armv5*) ARCH="armv5" ;; + armv6*) ARCH="armv6" ;; + armv7*) ARCH="armv7" ;; + aarch64) ARCH="arm64" ;; + x86) ARCH="386" ;; + x86_64) ARCH="amd64" ;; + i686) ARCH="386" ;; + i386) ARCH="386" ;; + ppc64le) ARCH="ppc64le" ;; + s390x) ARCH="s390x" ;; + esac } # initOS discovers the operating system for this system. initOS() { - OS=$(uname -s) - case "$OS" in - Windows_NT) OS='windows' ;; - # Msys support - MSYS*) OS='windows' ;; - # Minimalist GNU for Windows - MINGW*) OS='windows' ;; - CYGWIN*) OS='windows' ;; - Darwin) OS='macos' ;; - Linux) OS='linux' ;; - esac + OS=$(uname -s) + case "$OS" in + Windows_NT) OS='windows' ;; + # Msys support + MSYS*) OS='windows' ;; + # Minimalist GNU for Windows + MINGW*) OS='windows' ;; + CYGWIN*) OS='windows' ;; + Darwin) OS='macos' ;; + Linux) OS='linux' ;; + esac } # verifySupported checks that the os/arch combination is supported for # binary builds. verifySupported() { - supported="linux-amd64\nlinux-arm64\nlinux-armv6\nlinux-armv7\nlinux-ppc64le\nlinux-s390x\nfreebsd-amd64\nfreebsd-arm64\nmacos-amd64\nmacos-arm64\nwindows-amd64\nwindows-arm64" - if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then - echo "No prebuild binary for ${OS}-${ARCH}." - exit 1 - fi - - # Skip download tool check if using local file - if [ -z "$HELM_DIFF_BIN_TGZ" ]; then - if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then - echo "Either curl or wget is required" - exit 1 - fi - fi + supported="linux-amd64\nlinux-arm64\nlinux-armv6\nlinux-armv7\nlinux-ppc64le\nlinux-s390x\nfreebsd-amd64\nfreebsd-arm64\nmacos-amd64\nmacos-arm64\nwindows-amd64\nwindows-arm64" + if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then + echo "No prebuild binary for ${OS}-${ARCH}." + exit 1 + fi + + # Skip download tool check if using local file + if [ -z "$HELM_DIFF_BIN_TGZ" ]; then + if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then + echo "Either curl or wget is required" + exit 1 + fi + fi } # getDownloadURL checks the latest available version. getDownloadURL() { - # If HELM_DIFF_BIN_TGZ is set, we don't need a download URL - if [ -n "$HELM_DIFF_BIN_TGZ" ]; then - return - fi - version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :) - if [ "$SCRIPT_MODE" = "install" ] && [ -n "$version" ]; then - DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/helm-diff-$OS-$ARCH.tgz" - else - DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/latest/download/helm-diff-$OS-$ARCH.tgz" - fi + # If HELM_DIFF_BIN_TGZ is set, we don't need a download URL + if [ -n "$HELM_DIFF_BIN_TGZ" ]; then + return + fi + version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :) + if [ "$SCRIPT_MODE" = "install" ] && [ -n "$version" ]; then + DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/helm-diff-$OS-$ARCH.tgz" + else + DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/latest/download/helm-diff-$OS-$ARCH.tgz" + fi } # Temporary dir mkTempDir() { - HELM_TMP="$(mktemp -d -t "${PROJECT_NAME}-XXXXXX")" + HELM_TMP="$(mktemp -d -t "${PROJECT_NAME}-XXXXXX")" } rmTempDir() { - if [ -d "${HELM_TMP:-/tmp/helm-diff-tmp}" ]; then - rm -rf "${HELM_TMP:-/tmp/helm-diff-tmp}" - fi + if [ -d "${HELM_TMP:-/tmp/helm-diff-tmp}" ]; then + rm -rf "${HELM_TMP:-/tmp/helm-diff-tmp}" + fi } # downloadFile downloads the latest binary package and also the checksum # for that binary. downloadFile() { - PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" - - # If HELM_DIFF_BIN_TGZ is set, copy the local file instead of downloading - if [ -n "$HELM_DIFF_BIN_TGZ" ]; then - echo "Using local package at $HELM_DIFF_BIN_TGZ" - if [ ! -f "$HELM_DIFF_BIN_TGZ" ]; then - echo "Error: file not found at $HELM_DIFF_BIN_TGZ" - exit 1 - fi - cp "$HELM_DIFF_BIN_TGZ" "$PLUGIN_TMP_FILE" - return - fi - - echo "Downloading $DOWNLOAD_URL" - if command -v curl >/dev/null 2>&1; then - curl -sSf -L "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" - elif command -v wget >/dev/null 2>&1; then - wget -q -O - "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" - fi + PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" + + # If HELM_DIFF_BIN_TGZ is set, copy the local file instead of downloading + if [ -n "$HELM_DIFF_BIN_TGZ" ]; then + echo "Using local package at $HELM_DIFF_BIN_TGZ" + if [ ! -f "$HELM_DIFF_BIN_TGZ" ]; then + echo "Error: file not found at $HELM_DIFF_BIN_TGZ" + exit 1 + fi + cp "$HELM_DIFF_BIN_TGZ" "$PLUGIN_TMP_FILE" + return + fi + + echo "Downloading $DOWNLOAD_URL" + if command -v curl >/dev/null 2>&1; then + curl -sSf -L "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" + elif command -v wget >/dev/null 2>&1; then + wget -q -O - "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE" + fi } # Unpack the archive file, then install it into the helm directory. installFile() { - PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" - tar xzf "$PLUGIN_TMP_FILE" -C "$HELM_TMP" - HELM_TMP_BIN="$HELM_TMP/diff/bin/diff" - if [ "${OS}" = "windows" ]; then - HELM_TMP_BIN="$HELM_TMP_BIN.exe" - fi - echo "Preparing to install into ${HELM_PLUGIN_DIR}" - mkdir -p "$HELM_PLUGIN_DIR/bin" - cp "$HELM_TMP_BIN" "$HELM_PLUGIN_DIR/bin" + PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz" + tar xzf "$PLUGIN_TMP_FILE" -C "$HELM_TMP" + HELM_TMP_BIN="$HELM_TMP/diff/bin/diff" + if [ "${OS}" = "windows" ]; then + HELM_TMP_BIN="$HELM_TMP_BIN.exe" + fi + echo "Preparing to install into ${HELM_PLUGIN_DIR}" + mkdir -p "$HELM_PLUGIN_DIR/bin" + cp "$HELM_TMP_BIN" "$HELM_PLUGIN_DIR/bin" } # exit_trap is executed if on exit (error or not). exit_trap() { - result=$? - rmTempDir - if [ "$result" != "0" ]; then - echo "Failed to install $PROJECT_NAME" - printf '\tFor support, go to https://github.com/databus23/helm-diff.\n' - fi - exit $result + result=$? + rmTempDir + if [ "$result" != "0" ]; then + echo "Failed to install $PROJECT_NAME" + printf '\tFor support, go to https://github.com/databus23/helm-diff.\n' + fi + exit $result } # --- Execution --- From 39353d754976c1033eec75c9dd76e2030195b50b Mon Sep 17 00:00:00 2001 From: blackbrandt Date: Mon, 30 Mar 2026 08:33:22 -0500 Subject: [PATCH 6/8] Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c87c128c..b04ded89 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ $env:HELM_DIFF_BIN_TGZ = "C:\path\to\helm-diff-bin.tgz" ``` Now, run `helm plugin install /path/to/helm-diff/`. +Here, `/path/to/helm-diff/` must be a local copy of the Helm Diff plugin source directory (including `plugin.yaml` and the install scripts), for example from a repo you cloned or a source archive you downloaded earlier and transferred into the offline environment. The install script will skip the GitHub download and instead install from the `.tgz`. **For Helm 4 users:** From 09b47599f4c7feffdfd883115419eff8c49b1c49 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Mon, 30 Mar 2026 08:37:28 -0500 Subject: [PATCH 7/8] updating readme to specify grabbing correct architecture --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b04ded89..e4180a19 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,15 @@ helm plugin install https://github.com/databus23/helm-diff ``` ### Installing offline -If installing this in an offline/airgapped environment, download the bin `.tgz` from [releases](https://github.com/databus23/helm-diff/releases). Set `HELM_DIFF_BIN_TGZ` to the absolute path to the bin `.tgz`: + +If installing this in an offline/airgapped environment, download the platform-specific binary archive (e.g., `helm-diff-linux-amd64.tgz` or `helm-diff-windows-amd64.tgz`) from [releases](https://github.com/databus23/helm-diff/releases). Make sure to select the correct `.tgz` file for your operating system and architecture. + +Set `HELM_DIFF_BIN_TGZ` to the absolute path to the downloaded binary archive: **POSIX shell:** ```sh -export HELM_DIFF_BIN_TGZ=/path/to/helm-diff-bin.tgz -``` +export HELM_DIFF_BIN_TGZ=/path/to/helm-diff-linux-amd64.tgz + **PowerShell:** ```powershell From 77f3dcc509bcedc55c10fae30c733b9b11591571 Mon Sep 17 00:00:00 2001 From: Matt Fletcher Date: Mon, 30 Mar 2026 08:43:15 -0500 Subject: [PATCH 8/8] moving git version check to online install only --- install-binary.ps1 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 6f18f409..90e92261 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -46,25 +46,23 @@ function Download-Plugin { function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) Push-Location $ArchiveDirectory - tar -xzf $ArchiveName -C . + tar -xzf $ArchiveName -C . Pop-Location New-Item -ItemType Directory -Path $Destination -Force Copy-Item -Path (Join-Path $ArchiveDirectory "diff" "bin" "diff.exe") -Destination $Destination -Force } $ErrorActionPreference = "Stop" + $archiveName = "helm-diff.tgz" $arch = Get-Architecture -$version = Get-Version -Update $Update $tmpDir = New-TemporaryDirectory -trap { Remove-Item -path $tmpDir -Recurse -Force } - +trap { Remove-Item -path $tmpDir -Recurse -Force } $output = Join-Path $tmpDir $archiveName # Check for offline installation via environment variable if ($env:HELM_DIFF_BIN_TGZ) { Write-Host "HELM_DIFF_BIN_TGZ is set. Using local package at: $($env:HELM_DIFF_BIN_TGZ)" - if (-not (Test-Path $env:HELM_DIFF_BIN_TGZ -PathType Leaf)) { throw "Offline installation failed: File not found at '$($env:HELM_DIFF_BIN_TGZ)'" } @@ -72,10 +70,9 @@ if ($env:HELM_DIFF_BIN_TGZ) { } else { # Proceed with online installation - Write-Host "HELM_DIFF_BIN_TGZ not set. Proceeding with online installation." + $version = Get-Version -Update $Update $url = Get-Url -Version $version -Architecture $arch Download-Plugin -Url $url -Output $output } Install-Plugin -ArchiveDirectory $tmpDir -ArchiveName $archiveName -Destination (Join-Path $env:HELM_PLUGIN_DIR "bin") -