homebrew-core/Formula/krakend.rb

103 lines
3.0 KiB
Ruby

class Krakend < Formula
desc "Ultra-High performance API Gateway built in Go"
homepage "http://krakend.io/"
url "https://github.com/devopsfaith/krakend-ce/archive/0.4.0.tar.gz"
sha256 "c0e48b0e8234b1d7975c3dfa953f3c7568e4f1583c5ffb3fef95ee236a902afd"
bottle do
cellar :any_skip_relocation
sha256 "4dcb92551e3b2b0436f70dc7b488580543081cc6ae398557534ad5034728247c" => :high_sierra
sha256 "f7c0b5af16433dd039d9d3a640e6919ad9ae32d73f636a23b3617db08bff0808" => :sierra
sha256 "78c6d4f5a54f9ecebaca0f9806ef9ff3a3588bb941e3a0e2c971173507e0a392" => :el_capitan
end
depends_on "dep" => :build
depends_on "go" => :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_incomplete.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