111 lines
3.1 KiB
Ruby
111 lines
3.1 KiB
Ruby
class Consul < Formula
|
|
desc "Tool for service discovery, monitoring and configuration"
|
|
homepage "https://www.consul.io"
|
|
url "https://github.com/hashicorp/consul.git",
|
|
tag: "v1.9.5",
|
|
revision: "3c1c22679e9ca097211b3b6602da2e95a5d4401b"
|
|
license "MPL-2.0"
|
|
head "https://github.com/hashicorp/consul.git", shallow: false
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, big_sur: "043b458e21eae9cdfc7876df78cf7902629d63b17a2d3b95705e3e3181b7f1e7"
|
|
sha256 cellar: :any_skip_relocation, catalina: "233b60bc1fd40524e011cf99b0b41ebc3e924b6d0ea46866760eca6c7702f256"
|
|
sha256 cellar: :any_skip_relocation, mojave: "db6e019e1ec3ba55f5ba82482d61870e35c016c9172d41ed540e8c946d43f6d1"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "gox" => :build
|
|
|
|
uses_from_macos "zip" => :build
|
|
|
|
def install
|
|
# Specificy the OS, else all platforms will be built
|
|
on_macos do
|
|
ENV["XC_OS"] = "darwin"
|
|
end
|
|
on_linux do
|
|
ENV["XC_OS"] = "linux"
|
|
end
|
|
ENV["XC_ARCH"] = "amd64"
|
|
ENV["GOPATH"] = buildpath
|
|
contents = Dir["{*,.git,.gitignore}"]
|
|
(buildpath/"src/github.com/hashicorp/consul").install contents
|
|
|
|
(buildpath/"bin").mkpath
|
|
|
|
cd "src/github.com/hashicorp/consul" do
|
|
system "make"
|
|
bin.install "bin/consul"
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
plist_options manual: "consul agent -dev -bind 127.0.0.1"
|
|
|
|
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>
|
|
<dict>
|
|
<key>SuccessfulExit</key>
|
|
<false/>
|
|
</dict>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/consul</string>
|
|
<string>agent</string>
|
|
<string>-dev</string>
|
|
<string>-bind</string>
|
|
<string>127.0.0.1</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{var}</string>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/consul.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/consul.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
http_port = free_port
|
|
fork do
|
|
# most ports must be free, but are irrelevant to this test
|
|
system(
|
|
"#{bin}/consul",
|
|
"agent",
|
|
"-dev",
|
|
"-bind", "127.0.0.1",
|
|
"-dns-port", "-1",
|
|
"-grpc-port", "-1",
|
|
"-http-port", http_port,
|
|
"-serf-lan-port", free_port,
|
|
"-serf-wan-port", free_port,
|
|
"-server-port", free_port
|
|
)
|
|
end
|
|
|
|
# wait for startup
|
|
sleep 3
|
|
|
|
k = "brew-formula-test"
|
|
v = "value"
|
|
system "#{bin}/consul", "kv", "put", "-http-addr", "127.0.0.1:#{http_port}", k, v
|
|
assert_equal v, shell_output("#{bin}/consul kv get -http-addr 127.0.0.1:#{http_port} #{k}").chomp
|
|
end
|
|
end
|