Merge pull request #268059 from twz123/trivy-shell-completions

trivy: add shell completions
This commit is contained in:
Mario Rodas 2023-12-23 11:24:36 -05:00 committed by GitHub
commit 2c262faddb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,9 @@
{ lib
, stdenv
, buildPackages
, buildGoModule
, fetchFromGitHub
, installShellFiles
, testers
, trivy
}:
@ -29,9 +32,22 @@ buildGoModule rec {
"-X=github.com/aquasecurity/trivy/pkg/version.ver=v${version}"
];
nativeBuildInputs = [ installShellFiles ];
# Tests require network access
doCheck = false;
postInstall =
let
trivy = if stdenv.buildPlatform.canExecute stdenv.hostPlatform then placeholder "out" else buildPackages.trivy;
in
''
installShellCompletion --cmd trivy \
--bash <(${trivy}/bin/trivy completion bash) \
--fish <(${trivy}/bin/trivy completion fish) \
--zsh <(${trivy}/bin/trivy completion zsh)
'';
doInstallCheck = true;
passthru.tests.version = testers.testVersion {
@ -51,6 +67,7 @@ buildGoModule rec {
vulnerabilities of OS packages (Alpine, RHEL, CentOS, etc.) and
application dependencies (Bundler, Composer, npm, yarn, etc.).
'';
mainProgram = "trivy";
license = licenses.asl20;
maintainers = with maintainers; [ fab jk ];
};