Commit b9bf7575 authored by Matthieu Coudron's avatar Matthieu Coudron Committed by Eric Bailey
Browse files

kubernetes-helm: support plugins

also introduce helm-s3, helm-diff, helm-secrets plugin.

You can create a wrapped helm with these plugins via:

  myHelm = final.wrapHelm final.kubernetes-helm-unwrapped {
    plugins = with final.kubernetes-helmPlugins; [ helm-s3 helm-secrets helm-diff ];
  };

Running `helm plugin list` will show you these are available.
parent f456b461
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
{ stdenv, fetchFromGitHub, fetchurl, fetchzip }:
let

  buildHelmPlugin = { name, ... }@attrs:
    fetchzip (attrs // {
      stripRoot = false;
    });
in {

  helm-s3 = let
    pname = "helm-s3";
    version = "0.10.0";
  in buildHelmPlugin rec {
    name = "${pname}-${version}";
    url = "https://github.com/hypnoglow/helm-s3/releases/download/v${version}/helm-s3_${version}_linux_amd64.tar.gz";
    sha256 = "sha256-pTux7HArWB5yO1Oehfd+ZpeGUziI2+wfUart5WfkQW4=";

    extraPostFetch = ''
      mkdir $out/${pname}
      GLOBIGNORE="$out/${pname}"
      mv $out/* -t $out/${pname}
    '';
  };

  helm-diff = buildHelmPlugin {
    name = "helm-diff";
    url = "https://github.com/databus23/helm-diff/releases/download/v3.1.3/helm-diff-linux.tgz";
    sha256 = "sha256-oGmBPcCyUgq2YD4+CkGrbf6/JhzXJjmkaiqX/3a03aE=";
  };

  helm-secrets = buildHelmPlugin {
    name = "helm-secrets";
    url = "https://github.com/jkroepke/helm-secrets/releases/download/v3.4.1/helm-secrets.tar.gz";
    sha256 = "sha256-HXwbs/bXJXF75FbLB/En0jirCQnz8HpU3o9LeMyV0e8=";
  };
}
+48 −0
Original line number Diff line number Diff line
{ stdenv, symlinkJoin, lib, makeWrapper
, writeText
}:

helm:

let
  wrapper = {
    plugins ? [],
    extraMakeWrapperArgs ? ""
  }:
  let

  initialMakeWrapperArgs = [
      "${helm}/bin/helm" "${placeholder "out"}/bin/helm"
      "--argv0" "$0" "--set" "HELM_PLUGINS" "${pluginsDir}"
  ];

  pluginsDir = symlinkJoin {
    name = "helm-plugins";
    paths = plugins;
  };
in
  symlinkJoin {
    name = "helm-${lib.getVersion helm}";

    # Remove the symlinks created by symlinkJoin which we need to perform
    # extra actions upon
    postBuild = ''
      rm $out/bin/helm
      makeWrapper ${lib.escapeShellArgs initialMakeWrapperArgs}  ${extraMakeWrapperArgs}
    '';
    paths = [ helm pluginsDir ];

    preferLocalBuild = true;

    nativeBuildInputs = [ makeWrapper ];
    passthru = { unwrapped = helm; };

    meta = helm.meta // {
      # To prevent builds on hydra
      hydraPlatforms = [];
      # prefer wrapper over the package
      priority = (helm.meta.priority or 0) - 1;
    };
  };
in
  lib.makeOverridable wrapper
+6 −0
Original line number Diff line number Diff line
@@ -23401,6 +23401,12 @@ in
  kubernetes-helm = callPackage ../applications/networking/cluster/helm { };
  wrapHelm = callPackage ../applications/networking/cluster/helm/wrapper.nix { };
  kubernetes-helm-wrapped = wrapHelm kubernetes-helm-unwrapped {};
  kubernetes-helmPlugins = dontRecurseIntoAttrs (callPackage ../applications/networking/cluster/helm/plugins { });
  kubetail = callPackage ../applications/networking/cluster/kubetail { } ;
  kupfer = callPackage ../applications/misc/kupfer {