From 916656d8e3d5aeeb8a116477571c07d3f0d1ce94 Mon Sep 17 00:00:00 2001 From: jschaul Date: Wed, 25 Jan 2023 18:57:14 +0100 Subject: [PATCH] helm mapkubeapis plugin - also in offline packages See also https://github.com/wireapp/wire-server/pull/3019 and https://github.com/zinfra/cailleach/pull/1502 --- nix/overlay.nix | 7 ++++-- nix/pkgs/helm-mapkubeapis.nix | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 nix/pkgs/helm-mapkubeapis.nix diff --git a/nix/overlay.nix b/nix/overlay.nix index 15148d207..af9e9f7c0 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -1,4 +1,7 @@ -self: super: { +self: +let helm-mapkubeapis = self.callPackage ./pkgs/helm-mapkubeapis.nix { }; +in +super: { pythonForAnsible = (self.python3.withPackages (_: self.ansible.requiredPythonModules ++ [ super.python3Packages.boto super.python3Packages.boto3 @@ -11,7 +14,7 @@ self: super: { kubectl = self.callPackage ./pkgs/kubectl.nix { }; kubernetes-helm = super.wrapHelm super.kubernetes-helm { - plugins = with super.kubernetes-helmPlugins; [ helm-s3 helm-secrets helm-diff ]; + plugins = with super.kubernetes-helmPlugins; [ helm-s3 helm-secrets helm-diff helm-mapkubeapis ]; }; kubeadm = self.runCommandNoCC "kubeadm" { } "install -Dm0775 ${self.wire-binaries}/kubeadm $out/bin/kubeadm"; diff --git a/nix/pkgs/helm-mapkubeapis.nix b/nix/pkgs/helm-mapkubeapis.nix new file mode 100644 index 000000000..841ab4e4e --- /dev/null +++ b/nix/pkgs/helm-mapkubeapis.nix @@ -0,0 +1,40 @@ +{ buildGoModule, fetchFromGitHub, lib }: + +buildGoModule rec { + pname = "helm-mapkubeapis"; + # in case you change this version, ensure to set sha256 to empty string, as it will + # otherwise recompile but not actually update the version. Nix is not intuitive + # at all, this sucks! But you've been warned. :) + version = "0.1.0"; + + src = fetchFromGitHub { + owner = "helm"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-OIom+fMjLkbYXbxCsISuihdr3CWjUnkucTnDfoix9B0="; + }; + + vendorSha256 = "sha256-jqVzBRlGFhDHaiSF9AArJdt4KRCiUqUuo0CnJUTbSfE="; + + # NOTE: Remove the install and upgrade hooks. + postPatch = '' + sed -i '/^hooks:/,+2 d' plugin.yaml + ''; + + checkPhase = '' + ''; + + postInstall = '' + install -dm755 $out/${pname} + mv $out/bin $out/${pname}/ + install -m644 -Dt $out/${pname}/config/ config/Map.yaml + install -m644 -Dt $out/${pname} plugin.yaml + ''; + + meta = with lib; { + description = "A Helm plugin to map helm release deprecated Kubernetes APIs in-place"; + homepage = "https://github.com/helm/helm-mapkubeapis"; + license = licenses.asl20; + maintainers = with maintainers; [ ]; + }; +}