2013-09-16 11:06:27 +00:00
|
|
|
class Etcd < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "Key value store for shared configuration and service discovery"
|
2014-07-20 18:47:35 +00:00
|
|
|
homepage "https://github.com/coreos/etcd"
|
2015-04-23 04:13:29 +00:00
|
|
|
url "https://github.com/coreos/etcd/archive/v2.0.10.tar.gz"
|
|
|
|
sha256 "6029113d9870e5c6f0d10adbd2b6670958a46575114a094b86b607771a0e5ff3"
|
2014-07-20 18:47:35 +00:00
|
|
|
head "https://github.com/coreos/etcd.git"
|
2013-09-16 11:06:27 +00:00
|
|
|
|
2014-06-14 11:33:16 +00:00
|
|
|
bottle do
|
2015-04-23 16:10:40 +00:00
|
|
|
cellar :any
|
|
|
|
sha256 "b1bb954e636b25d75d41f3119c817b67bf3b3dcbd37dca7e95f79ada8782a506" => :yosemite
|
|
|
|
sha256 "c0af5a4ef05c4c09e4a2e20610cbc49e6cc6bb389f79f84f03497da44ed631f0" => :mavericks
|
|
|
|
sha256 "09d0f70cfcce1a5e5e922d39d4d3f232adc1a08beb3a2a00dd282fcb6c4f95ac" => :mountain_lion
|
2014-06-14 11:33:16 +00:00
|
|
|
end
|
|
|
|
|
2014-07-20 18:47:35 +00:00
|
|
|
depends_on "go" => :build
|
2013-09-16 11:06:27 +00:00
|
|
|
|
|
|
|
def install
|
2014-07-20 18:47:35 +00:00
|
|
|
ENV["GOPATH"] = buildpath
|
2013-09-16 11:06:27 +00:00
|
|
|
system "./build"
|
2014-07-20 18:47:35 +00:00
|
|
|
bin.install "bin/etcd"
|
2015-03-08 17:24:17 +00:00
|
|
|
bin.install "bin/etcdctl"
|
2013-09-16 11:06:27 +00:00
|
|
|
end
|
2014-05-09 21:47:23 +00:00
|
|
|
|
2015-04-27 01:47:31 +00:00
|
|
|
test do
|
|
|
|
begin
|
|
|
|
require "utils/json"
|
|
|
|
test_string = "Hello from brew test!"
|
|
|
|
etcd_pid = fork do
|
|
|
|
exec "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:4001/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 = Utils::JSON.load(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
|
|
|
|
|
2014-05-09 21:47:23 +00:00
|
|
|
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
|
2013-09-16 11:06:27 +00:00
|
|
|
end
|