1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 testers,
7 harbor-cli,
8 installShellFiles,
9}:
10
11buildGoModule (finalAttrs: {
12 pname = "harbor-cli";
13 version = "0.0.8";
14
15 src = fetchFromGitHub {
16 owner = "goharbor";
17 repo = "harbor-cli";
18 rev = "v${finalAttrs.version}";
19 hash = "sha256-7Fi4FeWsLwTtNZhD8TfSBTMr/LKzUm6UO4aWC0eJFtQ=";
20 };
21
22 vendorHash = "sha256-gkPMyDX5CO7j6JX3AUNw9o/HApRwLHAd8mD25rq96Lk=";
23
24 excludedPackages = [
25 "dagger"
26 "doc"
27 ];
28
29 nativeBuildInputs = [ installShellFiles ];
30
31 ldflags = [
32 "-s"
33 "-w"
34 "-X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.Version=${finalAttrs.version}"
35 ];
36
37 doCheck = false; # Network required
38
39 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
40 export HOME="$(mktemp -d)"
41
42 installShellCompletion --cmd harbor \
43 --bash <($out/bin/harbor completion bash) \
44 --fish <($out/bin/harbor completion fish) \
45 --zsh <($out/bin/harbor completion zsh)
46 '';
47
48 passthru.tests.version = testers.testVersion {
49 package = harbor-cli;
50 command = "HOME=\"$(mktemp -d)\" harbor version";
51 };
52
53 meta = {
54 homepage = "https://github.com/goharbor/harbor-cli";
55 description = "Command-line tool facilitates seamless interaction with the Harbor container registry";
56 changelog = "https://github.com/goharbor/harbor-cli/releases/tag/v${finalAttrs.version}";
57 license = lib.licenses.asl20;
58 maintainers = with lib.maintainers; [ aaronjheng ];
59 mainProgram = "harbor";
60 };
61})