2017-05-10 15:29:28 +00:00
|
|
|
class Cockroach < Formula
|
|
|
|
desc "Distributed SQL database"
|
|
|
|
homepage "https://www.cockroachlabs.com"
|
|
|
|
url "https://binaries.cockroachdb.com/cockroach-v1.0.src.tgz"
|
|
|
|
version "1.0"
|
|
|
|
sha256 "ca87b10eec688195e0df4f85431b019f2980ae4b511ee321f91f945315efeb76"
|
|
|
|
head "https://github.com/cockroachdb/cockroach.git"
|
|
|
|
|
2017-05-14 01:07:30 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any_skip_relocation
|
|
|
|
sha256 "6985249e02d60f44d369b51c3371ebe65d3002b6db1f7769afa09f2cbe54c3a9" => :sierra
|
|
|
|
sha256 "cdfaab2efe1581e48597c368de211a75b6de12e32c598b0587e28dd5c29c4b9f" => :el_capitan
|
|
|
|
sha256 "c1637df663dfe64a7f38673f67c683512181773629e1f322b3c66de1425fa8a7" => :yosemite
|
|
|
|
end
|
|
|
|
|
2017-05-10 15:29:28 +00:00
|
|
|
depends_on "cmake" => :build
|
|
|
|
depends_on "go" => :build
|
|
|
|
depends_on "xz" => :build
|
|
|
|
|
|
|
|
def install
|
|
|
|
system "make", "install", "prefix=#{prefix}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
For local development only, this formula ships a launchd configuration to
|
|
|
|
start a single-node cluster that stores its data under:
|
|
|
|
#{var}/cockroach/
|
|
|
|
Instead of the default port of 8080, the node serves its admin UI at:
|
|
|
|
#{Formatter.url("http://localhost:26256")}
|
|
|
|
|
|
|
|
Do NOT use this cluster to store data you care about; it runs in insecure
|
|
|
|
mode and may expose data publicly in e.g. a DNS rebinding attack. To run
|
|
|
|
CockroachDB securely, please see:
|
|
|
|
#{Formatter.url("https://www.cockroachlabs.com/docs/secure-a-cluster.html")}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
plist_options :manual => "cockroach start --insecure"
|
|
|
|
|
|
|
|
def plist; <<-EOS.undent
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>Label</key>
|
|
|
|
<string>#{plist_name}</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
|
|
|
<string>#{opt_bin}/cockroach</string>
|
|
|
|
<string>start</string>
|
|
|
|
<string>--store=#{var}/cockroach/</string>
|
|
|
|
<string>--http-port=26256</string>
|
|
|
|
<string>--insecure</string>
|
|
|
|
<string>--host=localhost</string>
|
|
|
|
</array>
|
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{var}</string>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>KeepAlive</key>
|
|
|
|
<true/>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
begin
|
|
|
|
# Redirect stdout and stderr to a file, or else `brew test --verbose`
|
|
|
|
# will hang forever as it waits for stdout and stderr to close.
|
|
|
|
system "#{bin}/cockroach start --insecure --background &> start.out"
|
|
|
|
pipe_output("#{bin}/cockroach sql --insecure", <<-EOS.undent)
|
|
|
|
CREATE DATABASE bank;
|
|
|
|
CREATE TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL);
|
|
|
|
INSERT INTO bank.accounts VALUES (1, 1000.50);
|
|
|
|
EOS
|
|
|
|
output = pipe_output("#{bin}/cockroach sql --insecure --format=csv",
|
|
|
|
"SELECT * FROM bank.accounts;")
|
|
|
|
assert_equal <<-EOS.undent, output
|
|
|
|
1 row
|
|
|
|
id,balance
|
|
|
|
1,1000.50
|
|
|
|
EOS
|
|
|
|
ensure
|
|
|
|
system "#{bin}/cockroach", "quit", "--insecure"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|