faas-cli: add shell completion and version test

This commit is contained in:
superherointj 2022-09-21 18:41:23 -03:00
parent 55eb086779
commit 7ab32908cc

View File

@ -4,6 +4,9 @@
, fetchFromGitHub
, makeWrapper
, git
, installShellFiles
, testers
, faas-cli
}:
let
faasPlatform = platform:
@ -24,12 +27,10 @@ buildGoModule rec {
sha256 = "sha256-iUS8bhTZc7oy7qy0ydmbVW3BNa/lZ2Q+kYefBKrNRyc=";
};
nativeBuildInputs = [ makeWrapper ];
vendorSha256 = null;
CGO_ENABLED = 0;
vendorSha256 = null;
subPackages = [ "." ];
ldflags = [
@ -39,14 +40,25 @@ buildGoModule rec {
"-X github.com/openfaas/faas-cli/commands.Platform=${faasPlatform stdenv.targetPlatform}"
];
nativeBuildInputs = [ makeWrapper installShellFiles ];
postInstall = ''
wrapProgram "$out/bin/faas-cli" \
--prefix PATH : ${lib.makeBinPath [ git ]}
installShellCompletion --cmd metal \
--bash <($out/bin/faas-cli completion --shell bash) \
--zsh <($out/bin/faas-cli completion --shell zsh)
'';
passthru.tests.version = testers.testVersion {
command = "${faas-cli}/bin/faas-cli version --short-version --warn-update=false";
package = faas-cli;
};
meta = with lib; {
homepage = "https://github.com/openfaas/faas-cli";
description = "Official CLI for OpenFaaS ";
homepage = "https://github.com/openfaas/faas-cli";
license = licenses.mit;
maintainers = with maintainers; [ welteki techknowlogick ];
};