homebrew-core/Formula/krakend.rb

104 lines
3.2 KiB
Ruby

class Krakend < Formula
desc "Ultra-High performance API Gateway built in Go"
homepage "https://www.krakend.io/"
url "https://github.com/devopsfaith/krakend-ce/archive/v1.3.0.tar.gz"
sha256 "cefa30de81b139c81be99f434745b78c7b5be99c94bb3e8442e9acf4094957b8"
license "Apache-2.0"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "90513c0d8c6a7ec97ba7253fd513e90c97e6bc343a58e23724040a498479115d"
sha256 cellar: :any_skip_relocation, big_sur: "b970739f920f5b23b39552ffbe827b1f53ba8f5861f61f9ab3295f71e707787a"
sha256 cellar: :any_skip_relocation, catalina: "c5af19b1068385c961df0c88005f41fd0cb59c9ee28771ea7ca7ee43e38ddfad"
sha256 cellar: :any_skip_relocation, mojave: "42ecca58ac93e1918a8e36e54be022b46313308c4f76d0eaf1621f5e76debab1"
end
depends_on "go" => :build
def install
(buildpath/"src/github.com/devopsfaith/krakend-ce").install buildpath.children
cd "src/github.com/devopsfaith/krakend-ce" do
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", 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", 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