homebrew-core/Formula/kubernetes-cli.rb

62 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.19.4",
revision: "d360454c9bcd1634cf4cc52d1867af5491dc9c5f"
license "Apache-2.0"
head "https://github.com/kubernetes/kubernetes.git"
livecheck do
url :head
regex(/^v([\d.]+)$/i)
end
bottle do
cellar :any_skip_relocation
sha256 "fc37b7498498b8c56ad659f51ca8360be611bd82438d35e835c13804520d641d" => :big_sur
sha256 "6cd5a2595db0b35e4ad8a317ab2dd2b6876d7f5568803baf971c1a0adb938305" => :catalina
sha256 "1bb95e044688ecf81fb4d8e0cc7b8e4fd14f81ce7fb8f8d6ccb9f7cdc64129ee" => :mojave
sha256 "4e988d95a7d72acab1b06a5517de5cb45d666e3168ba1b6670319ed989c6a046" => :high_sierra
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