homebrew-core/Formula/operator-sdk.rb
2019-11-03 16:46:19 +11:00

63 lines
2.2 KiB
Ruby

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.12.0",
:revision => "2445fcda834ca4b7cf0d6c38fba6317fb219b469"
head "https://github.com/operator-framework/operator-sdk.git"
bottle do
sha256 "3c1a3096fa626aaad7d10ad6a93fe467141a33959814e70e51628965ed2f2e97" => :catalina
sha256 "be37a061411e49e92b16970dcbc2e6a418e3fedc090aadffe88dc6c2818dfb58" => :mojave
sha256 "d866ecd94c8ccc81fed99c2402f1ec3d49ea6d0933fbe4917786f9ead396c68c" => :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