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"
|
2016-07-03 07:23:59 +00:00
|
|
|
url "https://github.com/coreos/etcd/archive/v3.0.1.tar.gz"
|
|
|
|
sha256 "29ccdf960a3bdb72bff3f9082c2ce14a909fe9156e3309afd7288cb3e050dd2d"
|
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-09-23 08:40:37 +00:00
|
|
|
cellar :any_skip_relocation
|
2016-07-03 07:48:27 +00:00
|
|
|
sha256 "9674255f0b9077ee985e3986b9508356d0781e4cec3cfc2d5bee45167fbb260b" => :el_capitan
|
|
|
|
sha256 "62d72bb293eb4bc1a1015c8e5989004a095997c9654ab7b1daf14114ef50c37e" => :yosemite
|
|
|
|
sha256 "f63addcd6465e0ddefdece19d383c0520e650ab86d02d1b4eff0d942d898f233" => :mavericks
|
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
|
2016-07-03 07:23:59 +00:00
|
|
|
mkdir_p "src/github.com/coreos"
|
|
|
|
ln_s buildpath, "src/github.com/coreos/etcd"
|
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
|
|
|
|
2016-07-03 07:23:59 +00:00
|
|
|
plist_options :manual => "etcd"
|
|
|
|
|
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
|
2016-04-11 08:55:18 +00:00
|
|
|
|
|
|
|
test do
|
|
|
|
begin
|
|
|
|
require "utils/json"
|
|
|
|
test_string = "Hello from brew test!"
|
|
|
|
etcd_pid = fork do
|
2016-07-03 07:23:59 +00:00
|
|
|
exec bin/"etcd", "--force-new-cluster", "--data-dir=#{testpath}"
|
2016-04-11 08:55:18 +00:00
|
|
|
end
|
|
|
|
# sleep to let etcd get its wits about it
|
|
|
|
sleep 10
|
2016-07-03 07:23:59 +00:00
|
|
|
etcd_uri = "http://127.0.0.1:2379/v2/keys/brew_test"
|
2016-04-11 08:55:18 +00:00
|
|
|
system "curl", "--silent", "-L", etcd_uri, "-XPUT", "-d", "value=#{test_string}"
|
2016-07-03 07:23:59 +00:00
|
|
|
curl_output = shell_output("curl --silent -L #{etcd_uri}")
|
2016-04-11 08:55:18 +00:00
|
|
|
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
|
2013-09-16 11:06:27 +00:00
|
|
|
end
|