homebrew-core/Formula/stolon.rb

53 lines
2.2 KiB
Ruby

class Stolon < Formula
desc "Cloud native PostgreSQL manager for high availability"
homepage "https://github.com/sorintlab/stolon"
url "https://github.com/sorintlab/stolon.git",
tag: "v0.16.0",
revision: "920fe4b83c158a6fe496dd6427a3715b84c0b4e2"
license "Apache-2.0"
bottle do
cellar :any_skip_relocation
sha256 "8bbf533b32cba6f798e17aad03e6268c6fe66be84cac9801226217e40c9cc0a9" => :catalina
sha256 "fac96dde0102d1b0b7cd6e6dad8cb3bb3b7dfdee16f0fe98cbb439e4602a48e5" => :mojave
sha256 "3f82acb97ffd0f586b5c6c643237205f0df3c5d03ed2cbd01143aba404d0e1b7" => :high_sierra
end
depends_on "go" => :build
depends_on "consul" => :test
depends_on "postgresql"
def install
system "go", "build", "-ldflags", "-s -w -X github.com/sorintlab/stolon/cmd.Version=#{version}",
"-trimpath", "-o", bin/"stolonctl", "./cmd/stolonctl"
system "go", "build", "-ldflags", "-s -w -X github.com/sorintlab/stolon/cmd.Version=#{version}",
"-trimpath", "-o", bin/"stolon-keeper", "./cmd/keeper"
system "go", "build", "-ldflags", "-s -w -X github.com/sorintlab/stolon/cmd.Version=#{version}",
"-trimpath", "-o", bin/"stolon-sentinel", "./cmd/sentinel"
system "go", "build", "-ldflags", "-s -w -X github.com/sorintlab/stolon/cmd.Version=#{version}",
"-trimpath", "-o", bin/"stolon-proxy", "./cmd/proxy"
prefix.install_metafiles
end
test do
pid = fork do
exec "consul", "agent", "-dev"
end
sleep 2
assert_match "stolonctl version #{version}",
shell_output("#{bin}/stolonctl version 2>&1")
assert_match "nil cluster data: <nil>",
shell_output("#{bin}/stolonctl status --cluster-name test --store-backend consul 2>&1", 1)
assert_match "stolon-keeper version #{version}",
shell_output("#{bin}/stolon-keeper --version 2>&1")
assert_match "stolon-sentinel version #{version}",
shell_output("#{bin}/stolon-sentinel --version 2>&1")
assert_match "stolon-proxy version #{version}",
shell_output("#{bin}/stolon-proxy --version 2>&1")
Process.kill("TERM", pid)
Process.wait(pid)
end
end