2018-04-06 10:52:49 +00:00
|
|
|
class Hcloud < Formula
|
|
|
|
desc "Command-line interface for Hetzner Cloud"
|
|
|
|
homepage "https://github.com/hetznercloud/cli"
|
2018-08-08 09:48:03 +00:00
|
|
|
url "https://github.com/hetznercloud/cli/archive/v1.6.0.tar.gz"
|
|
|
|
sha256 "8ada1db53f812774666d579722bce1d63cfd0212a70dd0d3ca734608610584b1"
|
2018-04-06 10:52:49 +00:00
|
|
|
|
2018-04-10 01:46:31 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any_skip_relocation
|
2018-08-08 10:40:26 +00:00
|
|
|
sha256 "0c710c7c12c15a186411ccf4e919227f6615557400f127f51ddbb1aed2f6110b" => :high_sierra
|
|
|
|
sha256 "91fbe41966cd0e151a79eaa0440e07f7baec9557bb870e6457a35694ddace58e" => :sierra
|
|
|
|
sha256 "907f1daf1241855d5007bad92f8401521d2a0d1a8c7bf883e39777f4a6236d8f" => :el_capitan
|
2018-04-10 01:46:31 +00:00
|
|
|
end
|
|
|
|
|
2018-04-06 10:52:49 +00:00
|
|
|
depends_on "go" => :build
|
|
|
|
|
|
|
|
def install
|
|
|
|
ENV["GOPATH"] = buildpath
|
|
|
|
(buildpath/"src/github.com/hetznercloud/cli").install buildpath.children
|
|
|
|
|
|
|
|
cd "src/github.com/hetznercloud/cli" do
|
2018-05-30 12:00:37 +00:00
|
|
|
ldflags = "-w -X github.com/hetznercloud/cli/cli.Version=v#{version}"
|
2018-04-06 10:52:49 +00:00
|
|
|
system "go", "build", "-o", bin/"hcloud", "-ldflags", ldflags,
|
|
|
|
"./cmd/hcloud"
|
|
|
|
prefix.install_metafiles
|
|
|
|
end
|
|
|
|
|
|
|
|
output = Utils.popen_read("#{bin}/hcloud completion bash")
|
|
|
|
(bash_completion/"hcloud").write output
|
|
|
|
output = Utils.popen_read("#{bin}/hcloud completion zsh")
|
|
|
|
(zsh_completion/"_hcloud").write output
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
config_path = testpath/".config/hcloud/cli.toml"
|
|
|
|
ENV["HCLOUD_CONFIG"] = config_path
|
|
|
|
assert_match "", shell_output("#{bin}/hcloud context active")
|
|
|
|
config_path.write <<~EOS
|
|
|
|
active_context = "test"
|
|
|
|
[[contexts]]
|
|
|
|
name = "test"
|
|
|
|
token = "foobar"
|
|
|
|
EOS
|
|
|
|
assert_match "test", shell_output("#{bin}/hcloud context list")
|
|
|
|
assert_match "test", shell_output("#{bin}/hcloud context active")
|
2018-05-30 12:00:37 +00:00
|
|
|
assert_match "hcloud v#{version}", shell_output("#{bin}/hcloud version")
|
2018-04-06 10:52:49 +00:00
|
|
|
end
|
|
|
|
end
|