From 1327c48bb7805806cdc90832a0551b8eed2d93a4 Mon Sep 17 00:00:00 2001 From: superherointj <5861043+superherointj@users.noreply.github.com> Date: Thu, 22 Sep 2022 09:12:48 -0300 Subject: [PATCH] kubebuilder: add shell completion, version test * minor refactor to phases order --- .../cluster/kubebuilder/default.nix | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/networking/cluster/kubebuilder/default.nix b/pkgs/applications/networking/cluster/kubebuilder/default.nix index bf469c0f4b56..dd6e71a58abe 100644 --- a/pkgs/applications/networking/cluster/kubebuilder/default.nix +++ b/pkgs/applications/networking/cluster/kubebuilder/default.nix @@ -5,6 +5,9 @@ , git , go , gnumake +, installShellFiles +, testers +, kubebuilder }: buildGoModule rec { @@ -17,32 +20,47 @@ buildGoModule rec { rev = "v${version}"; sha256 = "sha256-nLjmz9OakBLTBWdYA6czgtJmCuP96abNwLcLZo+yZ48="; }; + vendorSha256 = "sha256-xljLDwubwr6rZ/ZpW9/WithClaMo88ivlBhWFb0iAvo="; subPackages = ["cmd"]; + allowGoReference = true; + ldflags = [ "-X main.kubeBuilderVersion=v${version}" "-X main.goos=${go.GOOS}" "-X main.goarch=${go.GOARCH}" - "-X main.gitCommit=v${version}" - "-X main.buildDate=v${version}" + "-X main.gitCommit=unknown" + "-X main.buildDate=unknown" ]; - doCheck = true; + nativeBuildInputs = [ + makeWrapper + git + installShellFiles + ]; postInstall = '' mv $out/bin/cmd $out/bin/kubebuilder wrapProgram $out/bin/kubebuilder \ --prefix PATH : ${lib.makeBinPath [ go gnumake ]} + + installShellCompletion --cmd kubebuilder \ + --bash <($out/bin/kubebuilder completion bash) \ + --fish <($out/bin/kubebuilder completion fish) \ + --zsh <($out/bin/kubebuilder completion zsh) ''; - allowGoReference = true; - nativeBuildInputs = [ makeWrapper git ]; + passthru.tests.version = testers.testVersion { + command = "${kubebuilder}/bin/kubebuilder version"; + package = kubebuilder; + version = "v${version}"; + }; meta = with lib; { - homepage = "https://github.com/kubernetes-sigs/kubebuilder"; description = "SDK for building Kubernetes APIs using CRDs"; + homepage = "https://github.com/kubernetes-sigs/kubebuilder"; license = licenses.asl20; maintainers = with maintainers; [ cmars ]; };