homebrew-core/Formula/krakend.rb
2018-10-04 19:38:45 +02:00

102 lines
3 KiB
Ruby

class Krakend < Formula
desc "Ultra-High performance API Gateway built in Go"
homepage "http://www.krakend.io/"
url "https://github.com/devopsfaith/krakend-ce/archive/0.6.1.tar.gz"
sha256 "f6dd5d8dbb5a3be488516ea5c0b3b234c80a330f7981891f64aaddd356302b2d"
bottle do
cellar :any_skip_relocation
sha256 "ea36616a60a95fd624391219b62354b13e4bed430a6aefacadbed094a56242d0" => :mojave
sha256 "d2f9f297f9e2b61298c84cba0f932da560c7754e0b51a53f007f15885107c6f4" => :high_sierra
sha256 "eb0ac15a6076f3ead96a99ca2bab0c10b334b52dfcae35081e059d3f46904c64" => :sierra
end
depends_on "dep" => :build
depends_on "go@1.10" => :build
def install
ENV["GOPATH"] = buildpath
(buildpath/"src/github.com/devopsfaith/krakend-ce").install buildpath.children
cd "src/github.com/devopsfaith/krakend-ce" do
system "make", "deps"
system "make", "build"
bin.install "krakend"
prefix.install_metafiles
end
end
test do
(testpath/"krakend_unsupported_version.json").write <<~EOS
{
"version": 1,
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "WARNING",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
}
}
}
EOS
assert_match "Unsupported version", shell_output("#{bin}/krakend check -c krakend_unsupported_version.json 2>&1")
(testpath/"krakend_bad_file.json").write <<~EOS
{
"version": 2,
"bad": file
}
EOS
assert_match "ERROR", shell_output("#{bin}/krakend check -c krakend_bad_file.json 2>&1")
(testpath/"krakend.json").write <<~EOS
{
"version": 2,
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "WARNING",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
}
},
"endpoints": [
{
"endpoint": "/test",
"method": "GET",
"concurrent_calls": 1,
"extra_config": {
"github_com/devopsfaith/krakend-httpsecure": {
"disable": true,
"allowed_hosts": [],
"ssl_proxy_headers": {}
},
"github.com/devopsfaith/krakend-ratelimit/juju/router": {
"maxRate": 0,
"clientMaxRate": 0
}
},
"backend": [
{
"url_pattern": "/backend",
"extra_config": {
"github.com/devopsfaith/krakend-oauth2-clientcredentials": {
"is_disabled": true,
"endpoint_params": {}
}
},
"encoding": "json",
"sd": "dns",
"host": [
"host1"
],
"disable_host_sanitize": true
}
]
}
]
}
EOS
assert_match "OK", shell_output("#{bin}/krakend check -c krakend.json 2>&1")
end
end