88 lines
2.9 KiB
Ruby
88 lines
2.9 KiB
Ruby
class Cockroach < Formula
|
|
desc "Distributed SQL database"
|
|
homepage "https://www.cockroachlabs.com"
|
|
url "https://binaries.cockroachdb.com/cockroach-v2.0.5.src.tgz"
|
|
version "2.0.5"
|
|
sha256 "2a3ba8e7a2c44f59644ad84b530930bdf09e597741033d73ee7b2e4490d2051d"
|
|
head "https://github.com/cockroachdb/cockroach.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "2550f29ae74ecd8ed8c1c418f6c175f4ff5c4d8cebf8728d2bd4568abe6536e9" => :high_sierra
|
|
sha256 "7e6ec310898ee4b029e99041c93427c36ed52b4b948ef694c7330e6cf2a37698" => :sierra
|
|
sha256 "abbb38d3b4fea74fa969519c2efe0c71d1fa30dc875c83276a778f71a8f9e2e7" => :el_capitan
|
|
end
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "cmake" => :build
|
|
depends_on "go" => :build
|
|
depends_on "xz" => :build
|
|
|
|
def install
|
|
system "make", "install", "prefix=#{prefix}"
|
|
end
|
|
|
|
def caveats; <<~EOS
|
|
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
|
|
<?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)
|
|
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, output
|
|
id,balance
|
|
1,1000.50
|
|
EOS
|
|
ensure
|
|
system "#{bin}/cockroach", "quit", "--insecure"
|
|
end
|
|
end
|
|
end
|