70 lines
2.2 KiB
Ruby
70 lines
2.2 KiB
Ruby
class Etcd < Formula
|
|
desc "Key value store for shared configuration and service discovery"
|
|
homepage "https://github.com/coreos/etcd"
|
|
url "https://github.com/coreos/etcd/archive/v3.0.16.tar.gz"
|
|
sha256 "ed9a63c7e5e2bd1b3323d0d8eaef854f3e21a1d8fc69c1f3fd4cce38e54247d4"
|
|
head "https://github.com/coreos/etcd.git"
|
|
|
|
bottle do
|
|
sha256 "734704debf2f2176b946daafc9512513bbabff640849ef9f785f19967d6428c6" => :sierra
|
|
sha256 "c1e0a22b70020ff70783357f43dc96d9f9663fb2dae2689821f1f495dd283b02" => :el_capitan
|
|
sha256 "19d12a9b6e79aa4de4077c17694624ad7e2278755389daf89d8b560fb85d6198" => :yosemite
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
mkdir_p "src/github.com/coreos"
|
|
ln_s buildpath, "src/github.com/coreos/etcd"
|
|
system "./build"
|
|
bin.install "bin/etcd"
|
|
bin.install "bin/etcdctl"
|
|
end
|
|
|
|
plist_options :manual => "etcd"
|
|
|
|
def plist; <<-EOS.undent
|
|
<?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
|