Skip to content

Commit

Permalink
chore(cli) remove deprecated compile CLI tool
Browse files Browse the repository at this point in the history
  • Loading branch information
p0pr0ck5 committed Dec 2, 2017
1 parent f740f22 commit 0200aeb
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 340 deletions.
1 change: 0 additions & 1 deletion kong-0.11.2-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ build = {
["kong.cmd.check"] = "kong/cmd/check.lua",
["kong.cmd.reload"] = "kong/cmd/reload.lua",
["kong.cmd.restart"] = "kong/cmd/restart.lua",
["kong.cmd.compile"] = "kong/cmd/compile.lua",
["kong.cmd.prepare"] = "kong/cmd/prepare.lua",
["kong.cmd.migrations"] = "kong/cmd/migrations.lua",
["kong.cmd.health"] = "kong/cmd/health.lua",
Expand Down
42 changes: 0 additions & 42 deletions kong/cmd/compile.lua

This file was deleted.

1 change: 0 additions & 1 deletion kong/cmd/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ local cmds = {
reload = true,
health = true,
check = true,
compile = true,
prepare = true,
migrations = true,
version = true,
Expand Down
276 changes: 0 additions & 276 deletions spec/01-unit/003-prefix_handler_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,282 +54,6 @@ describe("NGINX conf compiler", function()
end)
end)

describe("compile_kong_conf()", function()
it("compiles the Kong NGINX conf chunk", function()
local kong_nginx_conf = prefix_handler.compile_kong_conf(helpers.test_conf)
assert.matches("lua_package_path './?.lua;./?/init.lua;;;'", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9000;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9001;", kong_nginx_conf, nil, true)
assert.matches("server_name kong;", kong_nginx_conf, nil, true)
assert.matches("server_name kong_admin;", kong_nginx_conf, nil, true)
assert.not_matches("lua_ssl_trusted_certificate", kong_nginx_conf, nil, true)
end)
it("compiles with custom conf", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
mem_cache_size = "128k",
proxy_listen = "0.0.0.0:80",
admin_listen = "127.0.0.1:8001"
}))
local kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("lua_shared_dict kong_cache%s+128k;", kong_nginx_conf)
assert.matches("listen 0.0.0.0:80;", kong_nginx_conf, nil, true)
assert.matches("listen 127.0.0.1:8001;", kong_nginx_conf, nil, true)
end)
it("enables HTTP/2", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
http2 = true,
admin_http2 = true
}))
local kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("listen 0.0.0.0:9000;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9443 ssl http2;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9001;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:8444 ssl http2;", kong_nginx_conf, nil, true)

conf = assert(conf_loader(helpers.test_conf_path, {
http2 = true,
}))
kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("listen 0.0.0.0:9000;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9443 ssl http2;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9001;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:8444 ssl;", kong_nginx_conf, nil, true)

conf = assert(conf_loader(helpers.test_conf_path, {
admin_http2 = true
}))
kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("listen 0.0.0.0:9000;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9443 ssl;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9001;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:8444 ssl http2;", kong_nginx_conf, nil, true)
end)
it("enables proxy_protocol", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
real_ip_header = "proxy_protocol",
}))
local kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("listen 0.0.0.0:9000 proxy_protocol;", kong_nginx_conf, nil, true)
assert.matches("listen 0.0.0.0:9443 ssl proxy_protocol;", kong_nginx_conf, nil, true)
end)
it("disables SSL", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
ssl = false,
admin_ssl = false
}))
local kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.not_matches("listen %d+%.%d+%.%d+%.%d+:%d+ ssl;", kong_nginx_conf)
assert.not_matches("ssl_certificate", kong_nginx_conf)
assert.not_matches("ssl_certificate_key", kong_nginx_conf)
assert.not_matches("ssl_protocols", kong_nginx_conf)
assert.not_matches("ssl_certificate_by_lua_block", kong_nginx_conf)
end)
describe("handles client_ssl", function()
it("on", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
client_ssl = true,
client_ssl_cert = "spec/fixtures/kong_spec.crt",
client_ssl_cert_key = "spec/fixtures/kong_spec.key",
}))
local kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("proxy_ssl_certificate.*spec/fixtures/kong_spec.crt", kong_nginx_conf)
assert.matches("proxy_ssl_certificate_key.*spec/fixtures/kong_spec.key", kong_nginx_conf)
end)
it("off", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
client_ssl = false,
}))
local kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.not_matches("proxy_ssl_certificate.*spec/fixtures/kong_spec.crt", kong_nginx_conf)
assert.not_matches("proxy_ssl_certificate_key.*spec/fixtures/kong_spec.key", kong_nginx_conf)
end)
end)
it("does not include lua_ssl_trusted_certificate/lua_ssl_verify_depth by default", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
lua_ssl_verify_depth = "2"
}))
local kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.not_matches("lua_ssl_trusted_certificate", kong_nginx_conf, nil, true)
assert.not_matches("lua_ssl_verify_depth", kong_nginx_conf, nil, true)
end)
it("sets lua_ssl_trusted_certificate/lua_ssl_verify_depth", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
lua_ssl_trusted_certificate = "/path/to/ca.cert",
lua_ssl_verify_depth = "2"
}))
local kong_nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("lua_ssl_trusted_certificate '/path/to/ca.cert';", kong_nginx_conf, nil, true)
assert.matches("lua_ssl_verify_depth 2;", kong_nginx_conf, nil, true)
end)
it("compiles without anonymous reports", function()
local conf = assert(conf_loader(nil, {
anonymous_reports = false,
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.not_matches("error_log syslog:server=.+ error;", nginx_conf)
end)
it("compiles with anonymous reports", function()
local conf = assert(conf_loader(nil, {
anonymous_reports = true,
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("error_log syslog:server=.+:61828 error;", nginx_conf)
end)
it("defines the client_max_body_size by default", function()
local conf = assert(conf_loader(nil, {}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("client_max_body_size 0", nginx_conf, nil, true)
end)
it("writes the client_max_body_size as defined", function()
local conf = assert(conf_loader(nil, {
client_max_body_size = "1m",
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("client_max_body_size 1m", nginx_conf, nil, true)
end)
it("defines the client_body_buffer_size directive by default", function()
local conf = assert(conf_loader(nil, {}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("client_body_buffer_size 8k", nginx_conf, nil, true)
end)
it("writes the client_body_buffer_size directive as defined", function()
local conf = assert(conf_loader(nil, {
client_body_buffer_size = "128k",
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("client_body_buffer_size 128k", nginx_conf, nil, true)
end)
it("writes kong_cassandra shm if using Cassandra", function()
local conf = assert(conf_loader(nil, {
database = "cassandra",
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("lua_shared_dict%s+kong_cassandra", nginx_conf)
end)
it("does not write kong_cassandra shm if not using Cassandra", function()
local conf = assert(conf_loader(nil, {
database = "postgres",
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.not_matches("lua_shared_dict%s+kong_cassandra", nginx_conf)
end)

describe("user directive", function()
it("is not included by default", function()
local conf = assert(conf_loader(helpers.test_conf_path))
local nginx_conf = prefix_handler.compile_nginx_conf(conf)
assert.not_matches("user[^;]*;", nginx_conf, nil, true)
end)
it("is not included when 'nobody'", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
nginx_user = "nobody"
}))
local nginx_conf = prefix_handler.compile_nginx_conf(conf)
assert.not_matches("user[^;]*;", nginx_conf, nil, true)
end)
it("is not included when 'nobody nobody'", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
nginx_user = "nobody nobody"
}))
local nginx_conf = prefix_handler.compile_nginx_conf(conf)
assert.not_matches("user[^;]*;", nginx_conf, nil, true)
end)
it("is included when otherwise", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
nginx_user = "www_data www_data"
}))
local nginx_conf = prefix_handler.compile_nginx_conf(conf)
assert.matches("user www_data www_data;", nginx_conf, nil, true)
end)
end)

describe("ngx_http_realip_module settings", function()
it("defaults", function()
local conf = assert(conf_loader())
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("real_ip_header%s+X%-Real%-IP;", nginx_conf)
assert.matches("real_ip_recursive%s+off;", nginx_conf)
assert.not_matches("set_real_ip_from", nginx_conf)
end)

it("real_ip_recursive on", function()
local conf = assert(conf_loader(nil, {
real_ip_recursive = true,
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("real_ip_recursive%s+on;", nginx_conf)
end)

it("real_ip_recursive off", function()
local conf = assert(conf_loader(nil, {
real_ip_recursive = false,
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("real_ip_recursive%s+off;", nginx_conf)
end)

it("set_real_ip_from", function()
local conf = assert(conf_loader(nil, {
trusted_ips = "192.168.1.0/24,192.168.2.1,2001:0db8::/32"
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("set_real_ip_from%s+192.168.1.0/24", nginx_conf)
assert.matches("set_real_ip_from%s+192.168.1.0", nginx_conf)
assert.matches("set_real_ip_from%s+2001:0db8::/32", nginx_conf)
end)
it("proxy_protocol", function()
local conf = assert(conf_loader(nil, {
real_ip_header = "proxy_protocol"
}))
local nginx_conf = prefix_handler.compile_kong_conf(conf)
assert.matches("real_ip_header%s+proxy_protocol", nginx_conf)
assert.matches("listen 0.0.0.0:8000 proxy_protocol;", nginx_conf)
assert.matches("listen 0.0.0.0:8443 ssl proxy_protocol;", nginx_conf)
end)
end)
end)

describe("compile_nginx_conf()", function()
it("compiles a main NGINX conf", function()
local nginx_conf = prefix_handler.compile_nginx_conf(helpers.test_conf)
assert.matches("worker_processes 1;", nginx_conf, nil, true)
assert.matches("daemon on;", nginx_conf, nil, true)
end)
it("compiles with custom conf", function()
local conf = assert(conf_loader(helpers.test_conf_path, {
nginx_daemon = "off"
}))
local nginx_conf = prefix_handler.compile_nginx_conf(conf)
assert.matches("daemon off;", nginx_conf, nil, true)
end)
it("compiles without opinionated nginx optimizations", function()
local conf = assert(conf_loader(nil, {
nginx_optimizations = false,
}))
local nginx_conf = prefix_handler.compile_nginx_conf(conf)
assert.not_matches("worker_rlimit_nofile %d+;", nginx_conf)
assert.not_matches("worker_connections %d+;", nginx_conf)
assert.not_matches("multi_accept on;", nginx_conf)
end)
it("compiles with opinionated nginx optimizations", function()
local conf = assert(conf_loader(nil, {
nginx_optimizations = true,
}))
local nginx_conf = prefix_handler.compile_nginx_conf(conf)
assert.matches("worker_rlimit_nofile %d+;", nginx_conf)
assert.matches("worker_connections %d+;", nginx_conf)
assert.matches("multi_accept on;", nginx_conf)
end)
it("converts dns_resolver to string", function()
local nginx_conf = prefix_handler.compile_nginx_conf({
dns_resolver = { "8.8.8.8", "8.8.4.4" }
}, [[
"resolver ${{DNS_RESOLVER}} ipv6=off;"
]])
assert.matches("resolver 8.8.8.8 8.8.4.4 ipv6=off;", nginx_conf, nil, true)
end)
end)

describe("prepare_prefix()", function()
local tmp_config = conf_loader(helpers.test_conf_path, {
prefix = "servroot_tmp"
Expand Down
20 changes: 0 additions & 20 deletions spec/02-integration/02-cmd/03-compile_spec.lua

This file was deleted.

0 comments on commit 0200aeb

Please sign in to comment.