|
| 1 | +class HarborCli < Formula |
| 2 | + desc "CLI for Harbor container registry" |
| 3 | + homepage "https://github.com/goharbor/harbor-cli" |
| 4 | + url "https://github.com/goharbor/harbor-cli/archive/refs/tags/v0.0.14.tar.gz" |
| 5 | + sha256 "a0518de7b09f0aac262a556d51a149841846dc85a5a4a1eebe79b6da68b6468b" |
| 6 | + license "Apache-2.0" |
| 7 | + head "https://github.com/goharbor/harbor-cli.git", branch: "main" |
| 8 | + |
| 9 | + bottle do |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_tahoe: "7dba396bcb743afdb4369377188da49c0c7c9401ca02cda017a67f10c7366c0c" |
| 11 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "7dba396bcb743afdb4369377188da49c0c7c9401ca02cda017a67f10c7366c0c" |
| 12 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "7dba396bcb743afdb4369377188da49c0c7c9401ca02cda017a67f10c7366c0c" |
| 13 | + sha256 cellar: :any_skip_relocation, sonoma: "21873226774fb128fe5b9762315e54f7a22aaccd781e9a658546e88a8d648b91" |
| 14 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "e78633ed481ca1e21566ea4036a3cdc5c8cbc7276da376d5c37efe96f9b4f1f0" |
| 15 | + end |
| 16 | + |
| 17 | + depends_on "go" => :build |
| 18 | + |
| 19 | + def install |
| 20 | + ldflags = %W[ |
| 21 | + -s -w |
| 22 | + -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.Version=#{version} |
| 23 | + -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GoVersion=#{Formula["go"].version} |
| 24 | + -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GitCommit=#{tap.user} |
| 25 | + -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.BuildTime=#{time.iso8601} |
| 26 | + ] |
| 27 | + system "go", "build", *std_go_args(ldflags:, output: bin/"harbor"), "./cmd/harbor" |
| 28 | + |
| 29 | + generate_completions_from_executable(bin/"harbor", "completion", shells: [:bash, :zsh, :fish, :pwsh]) |
| 30 | + end |
| 31 | + |
| 32 | + test do |
| 33 | + assert_match version.to_s, shell_output("#{bin}/harbor version") |
| 34 | + |
| 35 | + output = shell_output("#{bin}/harbor repo list 2>&1", 1) |
| 36 | + assert_match "Error: failed to get project name", output |
| 37 | + end |
| 38 | +end |
0 commit comments