109 lines
3.2 KiB
Ruby
109 lines
3.2 KiB
Ruby
class Traefik < Formula
|
|
desc "Modern reverse proxy"
|
|
homepage "https://traefik.io/"
|
|
url "https://github.com/containous/traefik/releases/download/v2.1.4/traefik-v2.1.4.src.tar.gz"
|
|
version "2.1.4"
|
|
sha256 "927d22b6d9d4bcc3cad61a82317def3840ec7a661220f3f5d74808409c157854"
|
|
head "https://github.com/containous/traefik.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "63cdc07f1f3dbd766a7c7a2f2d5a97a69ff40d36b289f753994c647991205cd4" => :catalina
|
|
sha256 "808b22aee608325c512e9e6344d92444948529fe6d7d3d4b63727dd23b0e6f1d" => :mojave
|
|
sha256 "af40251502482de9e7b6ed897a94ebc14653116851ae17dc981a34e06c05829f" => :high_sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "go-bindata" => :build
|
|
|
|
def install
|
|
system "go", "generate"
|
|
system "go", "build",
|
|
"-ldflags", "-s -w -X github.com/containous/traefik/v2/pkg/version.Version=#{version}",
|
|
"-trimpath", "-o", bin/"traefik", "./cmd/traefik"
|
|
prefix.install_metafiles
|
|
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
|
|
require "socket"
|
|
|
|
ui_server = TCPServer.new(0)
|
|
http_server = TCPServer.new(0)
|
|
ui_port = ui_server.addr[1]
|
|
http_port = http_server.addr[1]
|
|
ui_server.close
|
|
http_server.close
|
|
|
|
(testpath/"traefik.toml").write <<~EOS
|
|
[global]
|
|
checkNewVersion = false
|
|
sendAnonymousUsage = false
|
|
[serversTransport]
|
|
insecureSkipVerify = true
|
|
[entryPoints]
|
|
[entryPoints.http]
|
|
address = ":#{http_port}"
|
|
[entryPoints.traefik]
|
|
address = ":#{ui_port}"
|
|
[log]
|
|
level = "ERROR"
|
|
format = "common"
|
|
[accessLog]
|
|
format = "common"
|
|
[api]
|
|
insecure = true
|
|
dashboard = true
|
|
debug = true
|
|
EOS
|
|
|
|
begin
|
|
pid = fork do
|
|
exec bin/"traefik", "--configfile=#{testpath}/traefik.toml"
|
|
end
|
|
sleep 5
|
|
cmd_http = "curl -sIm3 -XGET http://localhost:#{http_port}/"
|
|
assert_match /404 Not Found/m, shell_output(cmd_http)
|
|
sleep 1
|
|
cmd_ui = "curl -sIm3 -XGET http://localhost:#{ui_port}/dashboard/"
|
|
assert_match /200 OK/m, shell_output(cmd_ui)
|
|
ensure
|
|
Process.kill("HUP", pid)
|
|
end
|
|
|
|
assert_match version.to_s, shell_output("#{bin}/traefik version 2>&1")
|
|
end
|
|
end
|