homebrew-core/Formula/kubernetes-cli.rb

60 lines
1.9 KiB
Ruby

class KubernetesCli < Formula
desc "Kubernetes command-line interface"
homepage "https://kubernetes.io/"
url "https://github.com/kubernetes/kubernetes.git",
tag: "v1.20.4",
revision: "e87da0bd6e03ec3fea7933c4b5263d151aafd07c"
license "Apache-2.0"
head "https://github.com/kubernetes/kubernetes.git"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any_skip_relocation, big_sur: "afb2863bbea76a02a679f613a8dff63014c7abee3ca10db76911a40d5512e2c4"
sha256 cellar: :any_skip_relocation, catalina: "26cd1aaba450b81ae1f0536433f06ecd001be015b1d4cd2ee84ac0745176a505"
sha256 cellar: :any_skip_relocation, mojave: "20e9bc152b7e468fb2cc298934eac84fa606cf222d629deed4b6ad105eea3e90"
end
depends_on "go" => :build
uses_from_macos "rsync" => :build
def install
# Don't dirty the git tree
rm_rf ".brew_home"
# Make binary
system "make", "WHAT=cmd/kubectl"
bin.install "_output/bin/kubectl"
# Install bash completion
output = Utils.safe_popen_read("#{bin}/kubectl", "completion", "bash")
(bash_completion/"kubectl").write output
# Install zsh completion
output = Utils.safe_popen_read("#{bin}/kubectl", "completion", "zsh")
(zsh_completion/"_kubectl").write output
# 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
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