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.3.4.tar.gz" sha256 "95405df7febae747ebc34432977ac180ba007deb84fe97ccc16b64e1f8a0cd1f" head "https://github.com/coreos/etcd.git" bottle do cellar :any_skip_relocation sha256 "e1d61351074861afece7902e97abea9e738071ae113a6784cc77a2b9ad270b97" => :high_sierra sha256 "d4c6e309999a13ad54d08c57d2e7839a6eb37bc4aff3871e003adaaff0fe6f70" => :sierra sha256 "325b07bbc00530731ae0d2d223431110416bf14fc344d02f14ff95c7a1c85124" => :el_capitan 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 KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/etcd RunAtLoad WorkingDirectory #{var} 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