47 lines
1.8 KiB
Ruby
47 lines
1.8 KiB
Ruby
class K3d < Formula
|
|
desc "Little helper to run Rancher Lab's k3s in Docker"
|
|
homepage "https://k3d.io"
|
|
url "https://github.com/rancher/k3d/archive/v3.3.0.tar.gz"
|
|
sha256 "f253337e99685053958d8e799eee6bdc13bf117425d6c8af0a07d5508451a8f2"
|
|
license "MIT"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "a8a778f929bdb8610640ca4633bb1f6295b7b32dfc181b3704d35e6e76be11d0" => :big_sur
|
|
sha256 "cdd66d870390613591ece810c90775eb624f09e07901c0d25b947bd6c1f94a77" => :catalina
|
|
sha256 "8246119e04ec70ebd1a0b70fc974da45b48062b5994f95927749d8943ade5a07" => :mojave
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
system "go", "build",
|
|
"-mod", "vendor",
|
|
"-ldflags", "-s -w -X github.com/rancher/k3d/v#{version.major}/version.Version=v#{version}"\
|
|
" -X github.com/rancher/k3d/v#{version.major}/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
|
|
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 "No nodes found for given cluster", output
|
|
end
|
|
end
|