55 lines
1.9 KiB
Ruby
55 lines
1.9 KiB
Ruby
class ApacheBrooklynCli < Formula
|
|
desc "Apache Brooklyn command-line interface"
|
|
homepage "https://brooklyn.apache.org"
|
|
url "https://github.com/apache/brooklyn-client/archive/rel/apache-brooklyn-0.10.0.tar.gz"
|
|
sha256 "9273a30e8fea9b5ebdd11ea64ff9164e03500660d4be26e2bc13e4e09c1c9ecc"
|
|
|
|
bottle do
|
|
sha256 "0f4d805b9d8a7086c481310d13e5807e90561e0eadaa1597135700c8e7bf1327" => :sierra
|
|
sha256 "c8bf103b0bd822b5a3caf6200b28405c5de29f93998c69148b0a4edd2dc72035" => :el_capitan
|
|
sha256 "2f9ee7ed7223009df9a7ea14cfb56091acbf2d3d2b2e880504b917574d4044f4" => :yosemite
|
|
end
|
|
|
|
depends_on "glide" => :build
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["XC_OS"] = "darwin"
|
|
ENV["XC_ARCH"] = MacOS.prefer_64_bit? ? "amd64" : "386"
|
|
ENV["GOPATH"] = buildpath
|
|
ENV["GOBIN"] = bin
|
|
ENV["GLIDE_HOME"] = HOMEBREW_CACHE/"glide_home/#{name}"
|
|
(buildpath/"src/github.com/apache/brooklyn-client").install "cli"
|
|
cd "src/github.com/apache/brooklyn-client/cli" do
|
|
system "glide", "install"
|
|
system "go", "install", ".../br"
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
test do
|
|
require "socket"
|
|
|
|
server = TCPServer.new("localhost", 0)
|
|
pid_mock_brooklyn = fork do
|
|
loop do
|
|
socket = server.accept
|
|
response = '{"version":"1.2.3","buildSha1":"dummysha","buildBranch":"1.2.3"}'
|
|
socket.print "HTTP/1.1 200 OK\r\n" \
|
|
"Content-Type: application/json\r\n" \
|
|
"Content-Length: #{response.bytesize}\r\n" \
|
|
"Connection: close\r\n"
|
|
socket.print "\r\n"
|
|
socket.print response
|
|
socket.close
|
|
end
|
|
end
|
|
|
|
begin
|
|
mock_brooklyn_url = "http://localhost:#{server.addr[1]}"
|
|
assert_equal "Connected to Brooklyn version 1.2.3 at #{mock_brooklyn_url}\n", shell_output("#{bin}/br login #{mock_brooklyn_url}")
|
|
ensure
|
|
Process.kill("KILL", pid_mock_brooklyn)
|
|
end
|
|
end
|
|
end
|