about summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/helm
diff options
context:
space:
mode:
authorYongun Seong <nevivurn@nevi.dev>2024-01-20 01:24:46 +0900
committerYongun Seong <nevivurn@nevi.dev>2024-01-20 01:24:46 +0900
commit3b7b07ee3fa610c93a1e48489db245c70a6bb48e (patch)
tree4134078e16e8737205b85b23acac03e67e3165d8 /pkgs/applications/networking/cluster/helm
parent716c2bc96ae57cedec031b5e569dc8acaaec2e06 (diff)
kubernetes-helm: set k8sVersion to match upstream
Diffstat (limited to 'pkgs/applications/networking/cluster/helm')
-rw-r--r--pkgs/applications/networking/cluster/helm/default.nix15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkgs/applications/networking/cluster/helm/default.nix b/pkgs/applications/networking/cluster/helm/default.nix
index cb6ddb0015202..8ad5ed0ee2577 100644
--- a/pkgs/applications/networking/cluster/helm/default.nix
+++ b/pkgs/applications/networking/cluster/helm/default.nix
@@ -20,9 +20,24 @@ buildGoModule rec {
     "-X helm.sh/helm/v3/internal/version.gitCommit=${src.rev}"
   ];
 
+  preBuild = ''
+    # set k8s version to client-go version, to match upstream
+    K8S_MODULES_VER="$(go list -f '{{.Version}}' -m k8s.io/client-go)"
+    K8S_MODULES_MAJOR_VER="$(($(cut -d. -f1 <<<"$K8S_MODULES_VER") + 1))"
+    K8S_MODULES_MINOR_VER="$(cut -d. -f2 <<<"$K8S_MODULES_VER")"
+    old_ldflags="''${ldflags}"
+    ldflags="''${ldflags} -X helm.sh/helm/v3/pkg/lint/rules.k8sVersionMajor=''${K8S_MODULES_MAJOR_VER}"
+    ldflags="''${ldflags} -X helm.sh/helm/v3/pkg/lint/rules.k8sVersionMinor=''${K8S_MODULES_MINOR_VER}"
+    ldflags="''${ldflags} -X helm.sh/helm/v3/pkg/chartutil.k8sVersionMajor=''${K8S_MODULES_MAJOR_VER}"
+    ldflags="''${ldflags} -X helm.sh/helm/v3/pkg/chartutil.k8sVersionMinor=''${K8S_MODULES_MINOR_VER}"
+  '';
+
   __darwinAllowLocalNetworking = true;
 
   preCheck = ''
+    # restore ldflags for tests
+    ldflags="''${old_ldflags}"
+
     # skipping version tests because they require dot git directory
     substituteInPlace cmd/helm/version_test.go \
       --replace "TestVersion" "SkipVersion"