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/0.7.0.tar.gz" sha256 "d72aa3a1d17c875d73317eedbe9aea7fa8715ac953975cf3e34244ebfd74bf4b" bottle do cellar :any_skip_relocation sha256 "17f4c4a0c6b4a8f561334daa18ac687b850d3f95b6c7003c09087a79f4737499" => :mojave sha256 "a632ad23efea88712d57a6a868277aa3a1b93c3890e8e22deebe4112dfc3bf11" => :high_sierra sha256 "04a1242a6edfb84037966cf79bb57de03bcc81b96ecd6c775585f52b59554524" => :sierra 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_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