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.8.tar.gz" sha256 "f5bc74dd2de1c567a1a36d797399f20cb764069cb3cf3651a593dd7f8a88c616" head "https://github.com/coreos/etcd.git" bottle do cellar :any_skip_relocation sha256 "e1dff52cc445d0a1a499ded941788ede1adf050dc2ce89cf4ade07f16d9363c4" => :high_sierra sha256 "abbd49f7d2e933d3ebfa0df6cbf1fbbdd4ebf88b6d5736cc9c808c9fcbfc1d76" => :sierra sha256 "a589ad5d348b005e6d30c6569728d773f27647cf970e28e7a4ad64cd84733fe4" => :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