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.0.tar.gz" sha256 "dcfe164401c2230bb2136be4538c1db9750f5f27d9e12dcf069d0b08da1b2200" head "https://github.com/coreos/etcd.git" bottle do cellar :any_skip_relocation sha256 "a6253c3272ed3ccefb2b2f14a7ef8e361ebcb8cca6b08bc1fd994d8a4e4af717" => :high_sierra sha256 "300731adbc3cd123bf8555613d9ee25fc9b7dd2e9e3bb544ce70c8d80fb3fcca" => :sierra sha256 "f0496124457290e0fcc180e5ffca3cea89e9cba06ecf1fa1aad851e25ebe61ef" => :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