aad6c5f343
Closes #43264. Signed-off-by: Chongyu Zhu <i@lembacon.com> Closes #43271. Signed-off-by: Chongyu Zhu <i@lembacon.com> Closes #43279. Signed-off-by: Chongyu Zhu <i@lembacon.com>
77 lines
2.4 KiB
Ruby
77 lines
2.4 KiB
Ruby
class Etcd < Formula
|
|
desc "Key value store for shared configuration and service discovery"
|
|
homepage "https://github.com/etcd-io/etcd"
|
|
url "https://github.com/etcd-io/etcd.git",
|
|
:tag => "v3.3.15",
|
|
:revision => "94745a4eed0425653b3b4275a208d38babceeaec"
|
|
head "https://github.com/etcd-io/etcd.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "97a67c313f2f7929d0ead34ad7e4c68817d7e900a7e6c4f42e198ed891f94f9d" => :mojave
|
|
sha256 "65f24030be6eb743d63ecac7f37383f350aa8b76fdd088e14ce81aef4ddd3434" => :high_sierra
|
|
sha256 "b7d7223b85c04c9e2833640888e1a61d2b6546447e993238bc5e9e386413f6e6" => :sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GO111MODULE"] = "on"
|
|
ENV["GOPATH"] = buildpath
|
|
|
|
dir = buildpath/"src/github.com/etcd-io/etcd"
|
|
dir.install buildpath.children
|
|
|
|
cd dir do
|
|
system "go", "build", "-ldflags", "-X main.version=#{version}", "-o", bin/"etcd"
|
|
system "go", "build", "-ldflags", "-X main.version=#{version}", "-o", bin/"etcdctl"
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
plist_options :manual => "etcd"
|
|
|
|
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}/etcd</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{var}</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
begin
|
|
test_string = "Hello from brew test!"
|
|
etcd_pid = fork do
|
|
exec bin/"etcd", "--force-new-cluster", "--data-dir=#{testpath}"
|
|
end
|
|
# sleep to let etcd get its wits about it
|
|
sleep 10
|
|
etcd_uri = "http://127.0.0.1:2379/v2/keys/brew_test"
|
|
system "curl", "--silent", "-L", etcd_uri, "-XPUT", "-d", "value=#{test_string}"
|
|
curl_output = shell_output("curl --silent -L #{etcd_uri}")
|
|
response_hash = JSON.parse(curl_output)
|
|
assert_match(test_string, response_hash.fetch("node").fetch("value"))
|
|
ensure
|
|
# clean up the etcd process before we leave
|
|
Process.kill("HUP", etcd_pid)
|
|
end
|
|
end
|
|
end
|