btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / ku / kube-bench / package.nix
blobd24be8a0df4073ca233feb4fb3ac237685171465
1 { lib, buildGoModule, fetchFromGitHub, installShellFiles }:
3 buildGoModule rec {
4   pname = "kube-bench";
5   version = "0.9.0";
7   src = fetchFromGitHub {
8     owner = "aquasecurity";
9     repo = pname;
10     rev = "refs/tags/v${version}";
11     hash = "sha256-x6xCrxePB/TR7BP1kLiVFjv4pLUJu9JVh5/Y0ebOjvY=";
12   };
14   vendorHash = "sha256-d6GhZBHDSRgMVeglw8rhq5QF7gRH4hQOzTn0DZjvhiA=";
16   nativeBuildInputs = [ installShellFiles ];
18   ldflags = [
19     "-s"
20     "-w"
21     "-X github.com/aquasecurity/kube-bench/cmd.KubeBenchVersion=v${version}"
22   ];
24   postInstall = ''
25     mkdir -p $out/share/kube-bench/
26     mv ./cfg $out/share/kube-bench/
28     installShellCompletion --cmd kube-bench \
29       --bash <($out/bin/kube-bench completion bash) \
30       --fish <($out/bin/kube-bench completion fish) \
31       --zsh <($out/bin/kube-bench completion zsh)
32   '';
34   doInstallCheck = true;
35   installCheckPhase = ''
36     runHook preInstallCheck
37     $out/bin/kube-bench --help
38     $out/bin/kube-bench version | grep "v${version}"
39     runHook postInstallCheck
40   '';
42   meta = with lib; {
43     homepage = "https://github.com/aquasecurity/kube-bench";
44     changelog = "https://github.com/aquasecurity/kube-bench/releases/tag/v${version}";
45     description = "Checks whether Kubernetes is deployed according to security best practices as defined in the CIS Kubernetes Benchmark";
46     mainProgram = "kube-bench";
47     license = licenses.asl20;
48     maintainers = with maintainers; [ jk ];
49   };