From 253f75dd6548d6dcb276f9448e162a1a63118346 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Thu, 19 Dec 2024 20:53:48 +0800 Subject: [PATCH 01/15] refactor(plugin.yaml): enhance platform support and update commands Signed-off-by: yxxhero --- install-binary.ps1 | 75 ++++++++++++++++++++++++++++++++++++++++++++++ plugin.yaml | 28 +++++++++++++---- 2 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 install-binary.ps1 diff --git a/install-binary.ps1 b/install-binary.ps1 new file mode 100644 index 00000000..365493ed --- /dev/null +++ b/install-binary.ps1 @@ -0,0 +1,75 @@ +param ( + [switch] $Update = $false +) + +function Get-Architecture { + $architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture + + $arch = switch ($architecture) { + "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" +} + +function New-TemporaryDirectory { + $tmp = [System.IO.Path]::GetTempPath() + $name = (New-Guid).ToString("N") + $dir = New-Item -ItemType Directory -Path (Join-Path $tmp $name) + return $dir.FullName +} + +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" + } + return "https://github.com/databus23/helm-diff/releases/download/${Version}/helm-diff-windows-${Architecture}.tgz" +} + +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) + + tar -xzf (Join-Path $ArchiveDirectory $ArchiveName) -C $ArchiveDirectory + + 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 +$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 diff --git a/plugin.yaml b/plugin.yaml index 8e2a8183..d7e04c1e 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,11 +1,29 @@ -name: "diff" +name: diff # Version is the version of Helm plus the number of official builds for this # plugin version: "3.12.5" usage: "Preview helm upgrade changes as a diff" description: "Preview helm upgrade changes as a diff" useTunnel: true -command: "$HELM_PLUGIN_DIR/bin/diff" -hooks: - install: "$HELM_PLUGIN_DIR/install-binary.sh" - update: "$HELM_PLUGIN_DIR/install-binary.sh -u" +platformCommand: + - command: ${HELM_PLUGIN_DIR}/bin/diff + - os: windows + command: ${HELM_PLUGIN_DIR}\bin\diff.exe +platformHooks: + install: + - command: ${HELM_PLUGIN_DIR}/install-binary.sh + - os: windows + command: pwsh + args: + - -c + - ${HELM_PLUGIN_DIR}/install-binary.ps1 + update: + - command: ${HELM_PLUGIN_DIR}/install-binary.sh + args: + - -u + - os: windows + command: pwsh + args: + - -c + - ${HELM_PLUGIN_DIR}/install-binary.ps1 + - -Update \ No newline at end of file From 9832eb37cacff2f74f45829a9e0282648e516fcd Mon Sep 17 00:00:00 2001 From: yxxhero Date: Wed, 21 May 2025 17:41:52 +0800 Subject: [PATCH 02/15] comments config for v3.18.0+ only Signed-off-by: yxxhero --- plugin.yaml | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/plugin.yaml b/plugin.yaml index d7e04c1e..1e0bed89 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -9,21 +9,22 @@ platformCommand: - command: ${HELM_PLUGIN_DIR}/bin/diff - os: windows command: ${HELM_PLUGIN_DIR}\bin\diff.exe -platformHooks: - install: - - command: ${HELM_PLUGIN_DIR}/install-binary.sh - - os: windows - command: pwsh - args: - - -c - - ${HELM_PLUGIN_DIR}/install-binary.ps1 - update: - - command: ${HELM_PLUGIN_DIR}/install-binary.sh - args: - - -u - - os: windows - command: pwsh - args: - - -c - - ${HELM_PLUGIN_DIR}/install-binary.ps1 - - -Update \ No newline at end of file +# v3.18.0+ only +# platformHooks: +# install: +# - command: ${HELM_PLUGIN_DIR}/install-binary.sh +# - os: windows +# command: pwsh +# args: +# - -c +# - ${HELM_PLUGIN_DIR}/install-binary.ps1 +# update: +# - command: ${HELM_PLUGIN_DIR}/install-binary.sh +# args: +# - -u +# - os: windows +# command: pwsh +# args: +# - -c +# - ${HELM_PLUGIN_DIR}/install-binary.ps1 +# - -Update \ No newline at end of file From 29a8f1521d5c69abb80d4de177674cfff6619a0f Mon Sep 17 00:00:00 2001 From: yxxhero Date: Wed, 21 May 2025 17:51:04 +0800 Subject: [PATCH 03/15] fix install plugins.yaml Signed-off-by: yxxhero --- plugin.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin.yaml b/plugin.yaml index 1e0bed89..1d8b54bf 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -6,9 +6,16 @@ usage: "Preview helm upgrade changes as a diff" description: "Preview helm upgrade changes as a diff" useTunnel: true platformCommand: - - command: ${HELM_PLUGIN_DIR}/bin/diff + - os: linux + command: "${HELM_PLUGIN_DIR}/install-binary.sh" + - os: darwin + command: "${HELM_PLUGIN_DIR}/install-binary.sh" - os: windows - command: ${HELM_PLUGIN_DIR}\bin\diff.exe + command: pwsh + args: + - -c + - ${HELM_PLUGIN_DIR}/install-binary.ps1 + # v3.18.0+ only # platformHooks: # install: From 00e0c0e15d455655a8f1af1a9611eb1761a9d061 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Thu, 22 May 2025 16:55:53 +0800 Subject: [PATCH 04/15] fix more issue Signed-off-by: yxxhero --- plugin.yaml | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/plugin.yaml b/plugin.yaml index 1d8b54bf..9946f361 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -6,32 +6,25 @@ usage: "Preview helm upgrade changes as a diff" description: "Preview helm upgrade changes as a diff" useTunnel: true platformCommand: - - os: linux - command: "${HELM_PLUGIN_DIR}/install-binary.sh" - - os: darwin - command: "${HELM_PLUGIN_DIR}/install-binary.sh" + - command: ${HELM_PLUGIN_DIR}/bin/diff - os: windows - command: pwsh - args: - - -c - - ${HELM_PLUGIN_DIR}/install-binary.ps1 + command: ${HELM_PLUGIN_DIR}\bin\diff.exe -# v3.18.0+ only -# platformHooks: -# install: -# - command: ${HELM_PLUGIN_DIR}/install-binary.sh -# - os: windows -# command: pwsh -# args: -# - -c -# - ${HELM_PLUGIN_DIR}/install-binary.ps1 -# update: -# - command: ${HELM_PLUGIN_DIR}/install-binary.sh -# args: -# - -u -# - os: windows -# command: pwsh -# args: -# - -c -# - ${HELM_PLUGIN_DIR}/install-binary.ps1 -# - -Update \ No newline at end of file +platformHooks: + install: + - command: ${HELM_PLUGIN_DIR}/install-binary.sh + - os: windows + command: pwsh + args: + - -c + - ${HELM_PLUGIN_DIR}/install-binary.ps1 + update: + - command: ${HELM_PLUGIN_DIR}/install-binary.sh + args: + - -u + - os: windows + command: pwsh + args: + - -c + - ${HELM_PLUGIN_DIR}/install-binary.ps1 + - -Update \ No newline at end of file From 8b6b1ea781c0e1d11882a73dc7bfeae312cad95d Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sat, 6 Sep 2025 20:56:53 +0800 Subject: [PATCH 05/15] use v3.19.0-rc.1 to be added the ci Signed-off-by: yxxhero --- .github/workflows/ci.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 53d4d24a..13651663 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,7 +43,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] shell: [ default ] experimental: [ false ] - helm-version: [ v3.18.6, v3.17.4 ] + helm-version: [ v3.18.6, v3.19.0-rc.1 ] include: - os: windows-latest shell: wsl @@ -61,16 +61,16 @@ jobs: - os: windows-latest shell: wsl experimental: false - helm-version: v3.17.4 + helm-version: v3.19.0-rc.1 - os: windows-latest shell: cygwin experimental: false - helm-version: v3.17.4 + helm-version: v3.19.0-rc.1 - os: ubuntu-latest container: alpine shell: sh experimental: false - helm-version: v3.17.4 + helm-version: v3.19.0-rc.1 steps: - name: Disable autocrlf @@ -111,7 +111,7 @@ jobs: # That's why we cover only 2 Helm minor versions in this matrix. # See https://github.com/helmfile/helmfile/pull/286#issuecomment-1250161182 for more context. - helm-version: v3.18.6 - - helm-version: v3.17.4 + - helm-version: v3.19.0-rc.1 steps: - uses: engineerd/setup-kind@v0.6.2 with: From c0ffceda9f45783ea01adad41d7709b3fdc46839 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 07:22:48 +0800 Subject: [PATCH 06/15] add --force-local for tar in windows platform Signed-off-by: yxxhero --- install-binary.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 365493ed..0f0dfea0 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -53,7 +53,7 @@ function Download-Plugin { function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) - tar -xzf (Join-Path $ArchiveDirectory $ArchiveName) -C $ArchiveDirectory + tar -xzf --force-local (Join-Path $ArchiveDirectory $ArchiveName) -C $ArchiveDirectory New-Item -ItemType Directory -Path $Destination -Force Copy-Item -Path (Join-Path $ArchiveDirectory "diff" "bin" "diff.exe") -Destination $Destination -Force From 8af3a7511c1ba0d1c67f7fba1820cdc618d43edb Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 07:27:39 +0800 Subject: [PATCH 07/15] fix --force-local for tar in windows platform Signed-off-by: yxxhero --- install-binary.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 0f0dfea0..6673e802 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -53,7 +53,7 @@ function Download-Plugin { function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) - tar -xzf --force-local (Join-Path $ArchiveDirectory $ArchiveName) -C $ArchiveDirectory + tar --force-local -xzf (Join-Path $ArchiveDirectory $ArchiveName) -C $ArchiveDirectory New-Item -ItemType Directory -Path $Destination -Force Copy-Item -Path (Join-Path $ArchiveDirectory "diff" "bin" "diff.exe") -Destination $Destination -Force From 4b429b1e02205046c8f62dd10281cb51fee3f3de Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 07:48:55 +0800 Subject: [PATCH 08/15] fix tar issue Signed-off-by: yxxhero --- install-binary.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 6673e802..65d8280c 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -53,7 +53,9 @@ function Download-Plugin { function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) - tar --force-local -xzf (Join-Path $ArchiveDirectory $ArchiveName) -C $ArchiveDirectory + Push-Location $ArchiveDirectory + tar -xzf $ArchiveName -C $ArchiveDirectory + Pop-Location New-Item -ItemType Directory -Path $Destination -Force Copy-Item -Path (Join-Path $ArchiveDirectory "diff" "bin" "diff.exe") -Destination $Destination -Force From 920fc81677312e44f8946af975bc7afc2e2246e7 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 08:28:58 +0800 Subject: [PATCH 09/15] debug ore issue Signed-off-by: yxxhero --- .github/workflows/ci.yaml | 2 -- install-binary.ps1 | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 13651663..4aaa2b42 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,8 +93,6 @@ jobs: - name: Setup Cygwin if: "contains(matrix.shell, 'cygwin')" uses: egor-tensin/setup-cygwin@v4 - with: - platform: x64 - name: helm plugin install run: helm plugin install . diff --git a/install-binary.ps1 b/install-binary.ps1 index 65d8280c..b11ae301 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -55,6 +55,7 @@ function Install-Plugin { Push-Location $ArchiveDirectory tar -xzf $ArchiveName -C $ArchiveDirectory + Get-ChildItem -Path $ArchiveDirectory -Recurse Pop-Location New-Item -ItemType Directory -Path $Destination -Force From 5b3029be5de213a60c44f7d47b81a8f39019117a Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 08:47:11 +0800 Subject: [PATCH 10/15] add -v for tar on windows Signed-off-by: yxxhero --- install-binary.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index b11ae301..29e64059 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -54,7 +54,7 @@ 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 $ArchiveDirectory + tar -xvzf $ArchiveName -C $ArchiveDirectory Get-ChildItem -Path $ArchiveDirectory -Recurse Pop-Location From 58ce392c5e0b07f5277fc5860906fdfac4bc0172 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 09:06:12 +0800 Subject: [PATCH 11/15] debug more info Signed-off-by: yxxhero --- install-binary.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/install-binary.ps1 b/install-binary.ps1 index 29e64059..8726eca0 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -54,6 +54,7 @@ function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) Push-Location $ArchiveDirectory + tar --help tar -xvzf $ArchiveName -C $ArchiveDirectory Get-ChildItem -Path $ArchiveDirectory -Recurse Pop-Location From b9bb72381fedfe180998ac060d65adca1a11ed84 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 09:25:14 +0800 Subject: [PATCH 12/15] debug more info Signed-off-by: yxxhero --- install-binary.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 8726eca0..149d2b97 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -53,8 +53,10 @@ function Download-Plugin { function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) + echo "archive directory: $ArchiveDirectory" + echo "archive name: $ArchiveName" + echo "destination: $Destination Push-Location $ArchiveDirectory - tar --help tar -xvzf $ArchiveName -C $ArchiveDirectory Get-ChildItem -Path $ArchiveDirectory -Recurse Pop-Location From 367720c1668380a3a10009ad683c19c8037f2c88 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 09:30:37 +0800 Subject: [PATCH 13/15] debug more info Signed-off-by: yxxhero --- install-binary.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 149d2b97..83f845d2 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -53,9 +53,9 @@ function Download-Plugin { function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) - echo "archive directory: $ArchiveDirectory" - echo "archive name: $ArchiveName" - echo "destination: $Destination + Write-Host "Archive directory: $ArchiveDirectory" + Write-Host "Archive name: $ArchiveName" + Write-Host "Destination: $Destination" Push-Location $ArchiveDirectory tar -xvzf $ArchiveName -C $ArchiveDirectory Get-ChildItem -Path $ArchiveDirectory -Recurse From 5e7dfe97861de9c7406b741ef916a42e72e5c6bc Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 09:52:26 +0800 Subject: [PATCH 14/15] debug more info Signed-off-by: yxxhero --- install-binary.ps1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 83f845d2..90e93f87 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -53,11 +53,8 @@ function Download-Plugin { function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) - Write-Host "Archive directory: $ArchiveDirectory" - Write-Host "Archive name: $ArchiveName" - Write-Host "Destination: $Destination" Push-Location $ArchiveDirectory - tar -xvzf $ArchiveName -C $ArchiveDirectory + tar -xvzf $ArchiveName -C . Get-ChildItem -Path $ArchiveDirectory -Recurse Pop-Location From 74e48eff3b2f29198a6e4eef63d8a1abd1f5c6b7 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 7 Sep 2025 09:57:51 +0800 Subject: [PATCH 15/15] remove debug options Signed-off-by: yxxhero --- install-binary.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install-binary.ps1 b/install-binary.ps1 index 90e93f87..e182b4c3 100644 --- a/install-binary.ps1 +++ b/install-binary.ps1 @@ -54,8 +54,7 @@ function Install-Plugin { param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination) Push-Location $ArchiveDirectory - tar -xvzf $ArchiveName -C . - Get-ChildItem -Path $ArchiveDirectory -Recurse + tar -xzf $ArchiveName -C . Pop-Location New-Item -ItemType Directory -Path $Destination -Force