Skip to content

Commit d0a1cb4

Browse files
MatthewFletcherMatt FletcherCopilot
authored
adding airgap install instructions (#964)
* adding airgap install instructions * remove extraneous lines * remove extraneous comments that did not apply to final code, applied shell script formatting * update readme to add concrete examples and follow syntax and formatting of the rest of the document * running shfmt -w on bash script/ * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * updating readme to specify grabbing correct architecture * moving git version check to online install only --------- Co-authored-by: Matt Fletcher <mfletcher36@gatech.edu> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e179da7 commit d0a1cb4

3 files changed

Lines changed: 69 additions & 39 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ This can also be used to compare two revisions/versions of your helm release.
2121
helm plugin install https://github.com/databus23/helm-diff
2222
```
2323

24+
### Installing offline
25+
26+
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.
27+
28+
Set `HELM_DIFF_BIN_TGZ` to the absolute path to the downloaded binary archive:
29+
30+
**POSIX shell:**
31+
```sh
32+
export HELM_DIFF_BIN_TGZ=/path/to/helm-diff-linux-amd64.tgz
33+
34+
35+
**PowerShell:**
36+
```powershell
37+
$env:HELM_DIFF_BIN_TGZ = "C:\path\to\helm-diff-bin.tgz"
38+
```
39+
40+
Now, run `helm plugin install /path/to/helm-diff/`.
41+
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.
42+
The install script will skip the GitHub download and instead install from the `.tgz`.
43+
2444
**For Helm 4 users:**
2545

2646
Helm 4 requires plugin verification by default. Since this plugin does not yet provide provenance artifacts, you need to use the `--verify=false` flag:

install-binary.ps1

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,22 @@ param (
44

55
function Get-Architecture {
66
$architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
7-
87
$arch = switch ($architecture) {
9-
"X64" { "amd64" }
8+
"X64" { "amd64" }
109
"Arm64" { "arm64" }
1110
Default { "" }
1211
}
13-
1412
if ($arch -eq "") {
1513
throw "Unsupported architecture: ${architecture}"
1614
}
17-
1815
return $arch
1916
}
2017

2118
function Get-Version {
2219
param ([Parameter(Mandatory=$true)][bool] $Update)
23-
2420
if ($Update) {
2521
return "latest"
2622
}
27-
2823
return git describe --tags --exact-match 2>$null || "latest"
2924
}
3025

@@ -37,7 +32,6 @@ function New-TemporaryDirectory {
3732

3833
function Get-Url {
3934
param ([Parameter(Mandatory=$true)][string] $Version, [Parameter(Mandatory=$true)][string] $Architecture)
40-
4135
if ($Version -eq "latest") {
4236
return "https://github.com/databus23/helm-diff/releases/latest/download/helm-diff-windows-${Architecture}.tgz"
4337
}
@@ -46,17 +40,14 @@ function Get-Url {
4640

4741
function Download-Plugin {
4842
param ([Parameter(Mandatory=$true)][string] $Url, [Parameter(Mandatory=$true)][string] $Output)
49-
5043
Invoke-WebRequest -OutFile $Output $Url
5144
}
5245

5346
function Install-Plugin {
5447
param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination)
55-
5648
Push-Location $ArchiveDirectory
57-
tar -xzf $ArchiveName -C .
49+
tar -xzf $ArchiveName -C .
5850
Pop-Location
59-
6051
New-Item -ItemType Directory -Path $Destination -Force
6152
Copy-Item -Path (Join-Path $ArchiveDirectory "diff" "bin" "diff.exe") -Destination $Destination -Force
6253
}
@@ -65,13 +56,23 @@ $ErrorActionPreference = "Stop"
6556

6657
$archiveName = "helm-diff.tgz"
6758
$arch = Get-Architecture
68-
$version = Get-Version -Update $Update
6959
$tmpDir = New-TemporaryDirectory
70-
71-
trap { Remove-Item -path $tmpDir -Recurse -Force }
72-
73-
$url = Get-Url -Version $version -Architecture $arch
60+
trap { Remove-Item -path $tmpDir -Recurse -Force }
7461
$output = Join-Path $tmpDir $archiveName
7562

76-
Download-Plugin -Url $url -Output $output
77-
Install-Plugin -ArchiveDirectory $tmpDir -ArchiveName $archiveName -Destination (Join-Path $env:HELM_PLUGIN_DIR "bin")
63+
# Check for offline installation via environment variable
64+
if ($env:HELM_DIFF_BIN_TGZ) {
65+
Write-Host "HELM_DIFF_BIN_TGZ is set. Using local package at: $($env:HELM_DIFF_BIN_TGZ)"
66+
if (-not (Test-Path $env:HELM_DIFF_BIN_TGZ -PathType Leaf)) {
67+
throw "Offline installation failed: File not found at '$($env:HELM_DIFF_BIN_TGZ)'"
68+
}
69+
Copy-Item -Path $env:HELM_DIFF_BIN_TGZ -Destination $output
70+
}
71+
else {
72+
# Proceed with online installation
73+
$version = Get-Version -Update $Update
74+
$url = Get-Url -Version $version -Architecture $arch
75+
Download-Plugin -Url $url -Output $output
76+
}
77+
78+
Install-Plugin -ArchiveDirectory $tmpDir -ArchiveName $archiveName -Destination (Join-Path $env:HELM_PLUGIN_DIR "bin")

install-binary.sh

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@ export GREP_COLOR="never"
1010
# available. This is the case when using MSYS2 or Cygwin
1111
# on Windows where helm returns a Windows path but we
1212
# need a Unix path
13-
1413
if command -v cygpath >/dev/null 2>&1; then
1514
HELM_BIN="$(cygpath -u "${HELM_BIN}")"
1615
HELM_PLUGIN_DIR="$(cygpath -u "${HELM_PLUGIN_DIR}")"
1716
fi
1817

1918
[ -z "$HELM_BIN" ] && HELM_BIN=$(command -v helm)
20-
2119
[ -z "$HELM_HOME" ] && HELM_HOME=$(helm env | grep 'HELM_DATA_HOME' | cut -d '=' -f2 | tr -d '"')
22-
2320
mkdir -p "$HELM_HOME"
24-
2521
: "${HELM_PLUGIN_DIR:="$HELM_HOME/plugins/helm-diff"}"
2622

2723
if [ "$SKIP_BIN_INSTALL" = "1" ]; then
@@ -55,7 +51,6 @@ initArch() {
5551
# initOS discovers the operating system for this system.
5652
initOS() {
5753
OS=$(uname -s)
58-
5954
case "$OS" in
6055
Windows_NT) OS='windows' ;;
6156
# Msys support
@@ -77,16 +72,21 @@ verifySupported() {
7772
exit 1
7873
fi
7974

80-
if
81-
! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1
82-
then
83-
echo "Either curl or wget is required"
84-
exit 1
75+
# Skip download tool check if using local file
76+
if [ -z "$HELM_DIFF_BIN_TGZ" ]; then
77+
if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then
78+
echo "Either curl or wget is required"
79+
exit 1
80+
fi
8581
fi
8682
}
8783

8884
# getDownloadURL checks the latest available version.
8985
getDownloadURL() {
86+
# If HELM_DIFF_BIN_TGZ is set, we don't need a download URL
87+
if [ -n "$HELM_DIFF_BIN_TGZ" ]; then
88+
return
89+
fi
9090
version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :)
9191
if [ "$SCRIPT_MODE" = "install" ] && [ -n "$version" ]; then
9292
DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/helm-diff-$OS-$ARCH.tgz"
@@ -99,6 +99,7 @@ getDownloadURL() {
9999
mkTempDir() {
100100
HELM_TMP="$(mktemp -d -t "${PROJECT_NAME}-XXXXXX")"
101101
}
102+
102103
rmTempDir() {
103104
if [ -d "${HELM_TMP:-/tmp/helm-diff-tmp}" ]; then
104105
rm -rf "${HELM_TMP:-/tmp/helm-diff-tmp}"
@@ -109,21 +110,29 @@ rmTempDir() {
109110
# for that binary.
110111
downloadFile() {
111112
PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz"
113+
114+
# If HELM_DIFF_BIN_TGZ is set, copy the local file instead of downloading
115+
if [ -n "$HELM_DIFF_BIN_TGZ" ]; then
116+
echo "Using local package at $HELM_DIFF_BIN_TGZ"
117+
if [ ! -f "$HELM_DIFF_BIN_TGZ" ]; then
118+
echo "Error: file not found at $HELM_DIFF_BIN_TGZ"
119+
exit 1
120+
fi
121+
cp "$HELM_DIFF_BIN_TGZ" "$PLUGIN_TMP_FILE"
122+
return
123+
fi
124+
112125
echo "Downloading $DOWNLOAD_URL"
113-
if
114-
command -v curl >/dev/null 2>&1
115-
then
126+
if command -v curl >/dev/null 2>&1; then
116127
curl -sSf -L "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE"
117-
elif
118-
command -v wget >/dev/null 2>&1
119-
then
128+
elif command -v wget >/dev/null 2>&1; then
120129
wget -q -O - "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE"
121130
fi
122131
}
123132

124-
# installFile verifies the SHA256 for the file, then unpacks and
125-
# installs it.
133+
# Unpack the archive file, then install it into the helm directory.
126134
installFile() {
135+
PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz"
127136
tar xzf "$PLUGIN_TMP_FILE" -C "$HELM_TMP"
128137
HELM_TMP_BIN="$HELM_TMP/diff/bin/diff"
129138
if [ "${OS}" = "windows" ]; then
@@ -145,11 +154,11 @@ exit_trap() {
145154
exit $result
146155
}
147156

148-
# Execution
149-
150-
#Stop execution on any error
157+
# --- Execution ---
158+
# Stop execution on any error
151159
trap "exit_trap" EXIT
152160
set -e
161+
153162
initArch
154163
initOS
155164
verifySupported

0 commit comments

Comments
 (0)