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.2.2.tar.gz" sha256 "dcbc38efb19c1a6238de01b8c2ced45209eec4f5c92239f2bc03a3c0db684e90" head "https://github.com/coreos/etcd.git" bottle do cellar :any_skip_relocation sha256 "f03e07c997615491179e914733017572e8632106d66403cf656f74f166f18e10" => :sierra sha256 "1fdbe93fcef5818e587a1fd01536b2195cadd21168b9b88968b80cc392fb425f" => :el_capitan sha256 "476883867ff5e75e314eb2e98d28a154cd4fdff3dd96231fb8db2d3d908d9d45" => :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 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