50 lines
1.9 KiB
Ruby
50 lines
1.9 KiB
Ruby
class K3d < Formula
|
|
desc "Little helper to run Rancher Lab's k3s in Docker"
|
|
homepage "https://github.com/rancher/k3d"
|
|
url "https://github.com/rancher/k3d/archive/v3.0.1.tar.gz"
|
|
sha256 "bcf9cf273033a81a97698c37cbf29146c17997f4bf3bedcd9fcf55db106b8db2"
|
|
license "MIT"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "ebb6a835a1ee1a138f1a1bdba89943c3141b661feca5493aa6f594787da5ebcf" => :catalina
|
|
sha256 "a21ff4cd19dab557a4a8d9b20f62dfe1344e4b74c0fa4b672ba26179c519584c" => :mojave
|
|
sha256 "18be677ae6d9acf0fdcc31697ed56ecd47dda337f66b1de0204eed8bfcde1440" => :high_sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
system "go", "build",
|
|
"-mod", "vendor",
|
|
"-ldflags", "-s -w -X github.com/rancher/k3d/v3/version.Version=v#{version}"\
|
|
" -X github.com/rancher/k3d/v3/version.K3sVersion=latest",
|
|
"-trimpath", "-o", bin/"k3d"
|
|
|
|
# Install bash completion
|
|
output = Utils.safe_popen_read("#{bin}/k3d", "completion", "bash")
|
|
(bash_completion/"k3d").write output
|
|
|
|
# Install zsh completion
|
|
output = Utils.safe_popen_read("#{bin}/k3d", "completion", "zsh")
|
|
(zsh_completion/"_k3d").write output
|
|
|
|
prefix.install_metafiles
|
|
end
|
|
|
|
test do
|
|
assert_match "k3d version v#{version}\nk3s version latest (default)", shell_output("#{bin}/k3d --version")
|
|
# Either docker is not present or it is, where the command will fail in the first case.
|
|
# In any case I wouldn't expect a cluster with name 6d6de430dbd8080d690758a4b5d57c86 to be present
|
|
# (which is the md5sum of 'homebrew-failing-test')
|
|
output = shell_output("#{bin}/k3d cluster get 6d6de430dbd8080d690758a4b5d57c86 2>&1", 1).split("\n").pop
|
|
assert_match output,
|
|
"\x1B\[31mFATA\x1B\[0m\[0000\]\ No\ nodes\ found\ for\ cluster\ '6d6de430dbd8080d690758a4b5d57c86'\ "
|
|
end
|
|
end
|