92 lines
2.7 KiB
Ruby
92 lines
2.7 KiB
Ruby
class Traefik < Formula
|
|
desc "Modern reverse proxy"
|
|
homepage "https://traefik.io/"
|
|
url "https://github.com/traefik/traefik/releases/download/v2.3.4/traefik-v2.3.4.src.tar.gz"
|
|
sha256 "ebc7d4fac18b8adbedb0e14fb7783a589e4ca0091cac4cbbcac20de249157ff1"
|
|
license "MIT"
|
|
head "https://github.com/containous/traefik.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "6c29de2aa47706ec6fa870d080f37d13fe15c98e551cf37221bc9888c6e5112f" => :big_sur
|
|
sha256 "752a534da6a70216e79a9cf2a551730d5a772b25363f040fa22a8624024bd55f" => :catalina
|
|
sha256 "0f3a9fcb3b7e94f80f7e841c4273ceee0f48dea22c1807c238191afad184c244" => :mojave
|
|
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/m, shell_output(cmd_ui)
|
|
sleep 1
|
|
cmd_ui = "curl -sIm3 -XGET http://127.0.0.1:#{ui_port}/dashboard/"
|
|
assert_match /200 OK/m, 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
|