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.11.0", :revision => "39c65c36159a9c249e5f3c178205cc6e86c16f8d" head "https://github.com/operator-framework/operator-sdk.git" bottle do sha256 "84f1dbe77b4fc35cc5474ea0aaca40dc8f9c10af07f657a9c8c2bff92baeea4d" => :catalina sha256 "4e99bf16da0a665919f18229c7f9d2e07c65ca769824b4c1485d7e4783714400" => :mojave sha256 "62c8379c0454ff218f36e69c89469f9f0f5da9fac6cc3c1260980c201d2bc7d6" => :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