class OperatorSdk < Formula desc "SDK for building Kubernetes applications" homepage "https://coreos.com/operators/" url "https://github.com/operator-framework/operator-sdk.git", :tag => "v0.14.0", :revision => "4fb185b9d45682473b4951c9788f845ba2fa5b12" head "https://github.com/operator-framework/operator-sdk.git" bottle do sha256 "290b9478ff1430eddb2dbaf5e4a63e35f1620079ce188f6bff07924613940676" => :catalina sha256 "d6eed5cf84fc0ffdc61891341210e94013836ebaba9bb53c088726204c0e18c3" => :mojave sha256 "01786054613e8f91cd55d9b6f38055cf24f3c0b2b11e28a98770a24c11438d67" => :high_sierra end depends_on "go" def install # TODO: Do not set GOROOT. This is a fix for failing tests when compiled with Go 1.13. # See https://github.com/Homebrew/homebrew-core/pull/43820. ENV["GOROOT"] = Formula["go"].opt_libexec ENV["GOPATH"] = buildpath dir = buildpath/"src/github.com/operator-framework/operator-sdk" dir.install buildpath.children - [buildpath/".brew_home"] dir.cd do # Make binary system "make", "install" bin.install buildpath/"bin/operator-sdk" # Install bash completion output = Utils.popen_read("#{bin}/operator-sdk completion bash") (bash_completion/"operator-sdk").write output # Install zsh completion output = Utils.popen_read("#{bin}/operator-sdk completion zsh") (zsh_completion/"_operator-sdk").write output prefix.install_metafiles end end test do # Use the offical golang module cache to prevent network flakes and allow # this test to complete before timing out. ENV["GOPROXY"] = "https://proxy.golang.org" if build.stable? version_output = shell_output("#{bin}/operator-sdk version") assert_match "version: \"v#{version}\"", version_output assert_match stable.specs[:revision], version_output end # Create a new, blank operator system "#{bin}/operator-sdk", "new", "test", "--repo=github.com/example-inc/app-operator" cd "test" do # Add an example API resource. This exercises most of the various pieces # of generation logic. system "#{bin}/operator-sdk", "add", "api", "--api-version=app.example.com/v1alpha1", "--kind=AppService" end end end