homebrew-core/Formula/kubernetes-cli.rb
2019-10-15 20:12:50 -04:00

61 lines
2.1 KiB
Ruby

class KubernetesCli < Formula
desc "Kubernetes command-line interface"
homepage "https://kubernetes.io/"
url "https://github.com/kubernetes/kubernetes.git",
:tag => "v1.16.2",
:revision => "c97fe5036ef3df2967d086711e6c0c405941e14b"
head "https://github.com/kubernetes/kubernetes.git"
bottle do
cellar :any_skip_relocation
sha256 "967500a577176ea53a926b2833619352dbf289e25977696515b32c7082f5e9e6" => :catalina
sha256 "12b5954c175d44077679d95d96497038f800dc2b9b836f1068d8446f4536f026" => :mojave
sha256 "26795827d1130e664cffd0fa2cfc53d681268d0da1180f7ac25b358acb62431a" => :high_sierra
end
depends_on "go@1.12" => :build
def install
ENV["GOPATH"] = buildpath
dir = buildpath/"src/k8s.io/kubernetes"
dir.install buildpath.children - [buildpath/".brew_home"]
cd dir do
# Race condition still exists in OS X Yosemite
# Filed issue: https://github.com/kubernetes/kubernetes/issues/34635
ENV.deparallelize { system "make", "generated_files" }
# Make binary
system "make", "kubectl"
bin.install "_output/local/bin/darwin/amd64/kubectl"
# Install bash completion
output = Utils.popen_read("#{bin}/kubectl completion bash")
(bash_completion/"kubectl").write output
# Install zsh completion
output = Utils.popen_read("#{bin}/kubectl completion zsh")
(zsh_completion/"_kubectl").write output
prefix.install_metafiles
# Install man pages
# Leave this step for the end as this dirties the git tree
system "hack/generate-docs.sh"
man1.install Dir["docs/man/man1/*.1"]
end
end
test do
run_output = shell_output("#{bin}/kubectl 2>&1")
assert_match "kubectl controls the Kubernetes cluster manager.", run_output
version_output = shell_output("#{bin}/kubectl version --client 2>&1")
assert_match "GitTreeState:\"clean\"", version_output
if build.stable?
assert_match stable.instance_variable_get(:@resource)
.instance_variable_get(:@specs)[:revision],
version_output
end
end
end