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.14.tar.gz" sha256 "96d5908b883a78b6caa3346867b620d04980a4545520ced0b6d1b3a0590f1546" head "https://github.com/coreos/etcd.git" bottle do cellar :any_skip_relocation sha256 "f29ceb9ff566f5c956198539220e53295e72e0b379e680e41bd6a1a8d030fc37" => :high_sierra sha256 "91f3e7532ea21eb63e33a51ee78390b7fd8b62981e6eff924da4c8efc653da2c" => :sierra sha256 "98f48b69a37dd7f5c835706ad44eae6b20d36a9d7ad85a2df3d9fa17241cef3c" => :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