53 lines
1.8 KiB
Ruby
53 lines
1.8 KiB
Ruby
class Fluxctl < Formula
|
|
desc "Command-line tool to access Weave Flux, the Kubernetes GitOps operator"
|
|
homepage "https://github.com/weaveworks/flux"
|
|
url "https://github.com/weaveworks/flux.git",
|
|
:tag => "1.15.0",
|
|
:revision => "7a09c08cbdfa6d157c2d2dc71d2011c5bbcfdad6"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "0b39b27c91aaa924086907a0249e3ae3ea4eac8b647f307e4f595db4d814c2ad" => :catalina
|
|
sha256 "51eccf51bddeef263b3a3c75d80245fd222a24f1de63391b36f86d3b79fd112a" => :mojave
|
|
sha256 "91e60598e6b67cde4ed3df3863112301bba60e830c85350769dd3820d60be6c9" => :high_sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
|
|
dir = buildpath/"src/github.com/weaveworks/flux"
|
|
dir.install buildpath.children
|
|
|
|
cd dir/"cmd/fluxctl" do
|
|
system "go", "build", "-ldflags", "-X main.version=#{version}", "-o", bin/"fluxctl"
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
test do
|
|
run_output = shell_output("#{bin}/fluxctl 2>&1")
|
|
assert_match "fluxctl helps you deploy your code.", run_output
|
|
|
|
version_output = shell_output("#{bin}/fluxctl version 2>&1")
|
|
assert_match version.to_s, version_output
|
|
|
|
# As we can't bring up a Kubernetes cluster in this test, we simply
|
|
# run "fluxctl sync" and check that it 1) errors out, and 2) complains
|
|
# about a missing .kube/config file.
|
|
require "pty"
|
|
require "timeout"
|
|
r, _w, pid = PTY.spawn("#{bin}/fluxctl sync", :err=>:out)
|
|
begin
|
|
Timeout.timeout(5) do
|
|
assert_match r.gets.chomp, "Error: Could not load kubernetes configuration file: invalid configuration: no configuration has been provided"
|
|
Process.wait pid
|
|
assert_equal 1, $CHILD_STATUS.exitstatus
|
|
end
|
|
rescue Timeout::Error
|
|
puts "process not finished in time, killing it"
|
|
Process.kill("TERM", pid)
|
|
end
|
|
end
|
|
end
|