tektoncd-cli: general maintenance (#445561)

This commit is contained in:
Sebastián Mancilla
2025-10-18 22:18:37 +00:00
committed by GitHub
+46 -24
View File
@@ -3,16 +3,23 @@
buildGoModule,
fetchFromGitHub,
installShellFiles,
writableTmpDirAsHomeHook,
stdenv,
buildPackages,
versionCheckHook,
}:
buildGoModule rec {
buildGoModule (finalAttrs: {
pname = "tektoncd-cli";
version = "0.42.0";
src = fetchFromGitHub {
owner = "tektoncd";
repo = "cli";
rev = "v${version}";
tag = "v${finalAttrs.version}";
sha256 = "sha256-WB3XsXT8bXo2GpHC6hGKilRwloy31y18JD09cQklsV0=";
};
@@ -21,47 +28,62 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-X github.com/tektoncd/cli/pkg/cmd/version.clientVersion=${version}"
"-X github.com/tektoncd/cli/pkg/cmd/version.clientVersion=${finalAttrs.version}"
];
# tests bind to ::1
__darwinAllowLocalNetworking = true;
nativeBuildInputs = [ installShellFiles ];
subPackages = [ "cmd/tkn" ];
subPackages = [
"cmd/tkn"
];
excludedPackages = [
"test/e2e"
];
nativeCheckInputs = [
writableTmpDirAsHomeHook
];
preCheck = ''
# some tests try to write to the home dir
export HOME="$TMPDIR"
# run all tests
unset subPackages
# the tests expect the clientVersion ldflag not to be set
unset ldflags
# remove tests with networking
rm pkg/cmd/version/version_test.go
'';
postInstall = ''
installManPage docs/man/man1/*
''
+ (
let
exe =
if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
"${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}"
else
lib.getExe buildPackages.tektoncd-cli;
in
''
installShellCompletion --cmd ${finalAttrs.meta.mainProgram} \
--bash <(${exe} completion bash) \
--fish <(${exe} completion fish) \
--zsh <(${exe} completion zsh)
''
);
installShellCompletion --cmd tkn \
--bash <($out/bin/tkn completion bash) \
--fish <($out/bin/tkn completion fish) \
--zsh <($out/bin/tkn completion zsh)
'';
nativeInstallCheckInputs = [
versionCheckHook
];
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/tkn --help
$out/bin/tkn version | grep "Client version: ${version}"
runHook postInstallCheck
'';
versionCheckProgramArg = "version";
meta = {
homepage = "https://tekton.dev";
changelog = "https://github.com/tektoncd/cli/releases/tag/v${version}";
changelog = "https://github.com/tektoncd/cli/releases/tag/${finalAttrs.src.tag}";
description = "Provides a CLI for interacting with Tekton - tkn";
longDescription = ''
The Tekton Pipelines cli project provides a CLI for interacting with
@@ -77,4 +99,4 @@ buildGoModule rec {
];
mainProgram = "tkn";
};
}
})