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.12.0", :revision => "fea56bc3feeedff7231e9647c306148f94d0d10e" bottle do cellar :any_skip_relocation sha256 "201b58c3acdede5a58ddcfdb874ab6bb9076cd564eba62d6fe1d8a3dcf7d6404" => :mojave sha256 "137ed14143b0532184b467aafae0f7bf0e742c5a9f4e6e9aaec084bba8eb83ca" => :high_sierra sha256 "724e95edc3b797bd3977895ca296ea42f1603dd881505d788a639570639e029c" => :sierra end depends_on "dep" => :build depends_on "go" => :build def install ENV["GOPATH"] = buildpath dir = buildpath/"src/github.com/weaveworks/flux" dir.install buildpath.children - [buildpath/".brew_home"] cd dir do system "dep", "ensure", "-vendor-only" system "make", "release-bins" bin.install "build/fluxctl_darwin_amd64" => "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