kubebuilder: add shell completion, version test

* minor refactor to phases order
This commit is contained in:
superherointj 2022-09-22 09:12:48 -03:00
parent 8fcb549a66
commit 1327c48bb7

View File

@ -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 ];
};