homebrew-core/Formula/fluxctl.rb
2019-06-13 20:10:11 +02:00

54 lines
1.9 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.13.0",
:revision => "4a1959d7b30068ebe54b29b907d5a4e4fbc920c5"
bottle do
cellar :any_skip_relocation
sha256 "b6a31ca0a4b99a840973e5033d03578b8349bed3c5113793027975a903c1a1ea" => :mojave
sha256 "0cdab0813dd5508ceb1cb5c721be65a0ca9448bddef2626d5a713f2a77109b10" => :high_sierra
sha256 "dfe150d06f635ae80cd653de1ed4501357aa7d8dd162a2fac057fbe8e4d52eca" => :sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
ENV["GO111MODULE"] = "on"
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