92 lines
2.9 KiB
Ruby
92 lines
2.9 KiB
Ruby
class Traefik < Formula
|
|
desc "Modern reverse proxy"
|
|
homepage "https://traefik.io/"
|
|
url "https://github.com/traefik/traefik/releases/download/v2.4.5/traefik-v2.4.5.src.tar.gz"
|
|
sha256 "06692c090d6b1f3b7bff7f8e6b77409420d3f5f8ce0526f05d0963b0fd6c6b1a"
|
|
license "MIT"
|
|
head "https://github.com/traefik/traefik.git"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "bc75254d3249c3a286d7300cbbdfd0b6ccb425faf99dd16f04012540be7a61ca"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "e963035e448aa1662d99db222cbc772a65b5409d63a71ac33604e4283286ad14"
|
|
sha256 cellar: :any_skip_relocation, catalina: "35824d46739ce025d594fe6e742150dca7e7a4281d5354c7a9ad58c62309d57c"
|
|
sha256 cellar: :any_skip_relocation, mojave: "1581bad629848255c70688bb9bc567be285e0cdcd640eeedfbbfff3904667b3b"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "go-bindata" => :build
|
|
|
|
def install
|
|
system "go", "generate"
|
|
system "go", "build",
|
|
"-ldflags", "-s -w -X github.com/traefik/traefik/v#{version.major}/pkg/version.Version=#{version}",
|
|
"-trimpath", "-o", bin/"traefik", "./cmd/traefik"
|
|
end
|
|
|
|
plist_options manual: "traefik"
|
|
|
|
def plist
|
|
<<~EOS
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>KeepAlive</key>
|
|
<false/>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/traefik</string>
|
|
<string>--configfile=#{etc/"traefik/traefik.toml"}</string>
|
|
</array>
|
|
<key>EnvironmentVariables</key>
|
|
<dict>
|
|
</dict>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{var}</string>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/traefik.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/traefik.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
ui_port = free_port
|
|
http_port = free_port
|
|
|
|
(testpath/"traefik.toml").write <<~EOS
|
|
[entryPoints]
|
|
[entryPoints.http]
|
|
address = ":#{http_port}"
|
|
[entryPoints.traefik]
|
|
address = ":#{ui_port}"
|
|
[api]
|
|
insecure = true
|
|
dashboard = true
|
|
EOS
|
|
|
|
begin
|
|
pid = fork do
|
|
exec bin/"traefik", "--configfile=#{testpath}/traefik.toml"
|
|
end
|
|
sleep 5
|
|
cmd_ui = "curl -sIm3 -XGET http://127.0.0.1:#{http_port}/"
|
|
assert_match "404 Not Found", shell_output(cmd_ui)
|
|
sleep 1
|
|
cmd_ui = "curl -sIm3 -XGET http://127.0.0.1:#{ui_port}/dashboard/"
|
|
assert_match "200 OK", shell_output(cmd_ui)
|
|
ensure
|
|
Process.kill(9, pid)
|
|
Process.wait(pid)
|
|
end
|
|
|
|
assert_match version.to_s, shell_output("#{bin}/traefik version 2>&1")
|
|
end
|
|
end
|