Fix reviews on inline lua
This commit is contained in:
parent
d049b2e652
commit
aa5c3ec010
8 changed files with 5 additions and 48 deletions
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
|
@ -83,10 +83,10 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
- name: Luacheck linter
|
- name: Lint Lua
|
||||||
uses: lunarmodules/luacheck@v1
|
uses: lunarmodules/luacheck@v1
|
||||||
with:
|
with:
|
||||||
args: --codes --globals lua_ingress --globals configuration --globals balancer --globals monitor --globals certificate --globals plugins --globals tcp_udp_configuration --globals tcp_udp_balancer --no-max-comment-line-length -q rootfs/etc/nginx/lua/
|
args: --codes --globals lua_ingress --globals configuration --globals balancer --globals monitor --globals certificate --globals tcp_udp_configuration --globals tcp_udp_balancer --no-max-comment-line-length -q rootfs/etc/nginx/lua/
|
||||||
|
|
||||||
test-go:
|
test-go:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -23,7 +23,6 @@ luacheck --codes --globals lua_ingress \
|
||||||
--globals balancer \
|
--globals balancer \
|
||||||
--globals monitor \
|
--globals monitor \
|
||||||
--globals certificate \
|
--globals certificate \
|
||||||
--globals plugins \
|
|
||||||
--globals tcp_udp_configuration \
|
--globals tcp_udp_configuration \
|
||||||
--globals tcp_udp_balancer \
|
--globals tcp_udp_balancer \
|
||||||
--no-max-comment-line-length -q rootfs/etc/nginx/lua/
|
--no-max-comment-line-length -q rootfs/etc/nginx/lua/
|
||||||
|
|
|
@ -291,7 +291,6 @@ var funcMap = text_template.FuncMap{
|
||||||
"filterRateLimits": filterRateLimits,
|
"filterRateLimits": filterRateLimits,
|
||||||
"buildRateLimitZones": buildRateLimitZones,
|
"buildRateLimitZones": buildRateLimitZones,
|
||||||
"buildRateLimit": buildRateLimit,
|
"buildRateLimit": buildRateLimit,
|
||||||
"configForLua": configForLua,
|
|
||||||
"locationConfigForLua": locationConfigForLua,
|
"locationConfigForLua": locationConfigForLua,
|
||||||
"buildResolvers": buildResolvers,
|
"buildResolvers": buildResolvers,
|
||||||
"buildUpstreamName": buildUpstreamName,
|
"buildUpstreamName": buildUpstreamName,
|
||||||
|
@ -418,41 +417,6 @@ func luaConfigurationRequestBodySize(c interface{}) string {
|
||||||
return dictKbToStr(size)
|
return dictKbToStr(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
// configForLua returns some general configuration as Lua table represented as string
|
|
||||||
func configForLua(input interface{}) string {
|
|
||||||
all, ok := input.(config.TemplateConfig)
|
|
||||||
if !ok {
|
|
||||||
klog.Errorf("expected a 'config.TemplateConfig' type but %T was given", input)
|
|
||||||
return "{}"
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf(`{
|
|
||||||
use_forwarded_headers = %t,
|
|
||||||
use_proxy_protocol = %t,
|
|
||||||
is_ssl_passthrough_enabled = %t,
|
|
||||||
http_redirect_code = %v,
|
|
||||||
listen_ports = { ssl_proxy = "%v", https = "%v" },
|
|
||||||
|
|
||||||
hsts = %t,
|
|
||||||
hsts_max_age = %v,
|
|
||||||
hsts_include_subdomains = %t,
|
|
||||||
hsts_preload = %t,
|
|
||||||
|
|
||||||
}`,
|
|
||||||
all.Cfg.UseForwardedHeaders,
|
|
||||||
all.Cfg.UseProxyProtocol,
|
|
||||||
all.IsSSLPassthroughEnabled,
|
|
||||||
all.Cfg.HTTPRedirectCode,
|
|
||||||
all.ListenPorts.SSLProxy,
|
|
||||||
all.ListenPorts.HTTPS,
|
|
||||||
|
|
||||||
all.Cfg.HSTS,
|
|
||||||
all.Cfg.HSTSMaxAge,
|
|
||||||
all.Cfg.HSTSIncludeSubdomains,
|
|
||||||
all.Cfg.HSTSPreload,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// locationConfigForLua formats some location specific configuration into Lua table represented as string
|
// locationConfigForLua formats some location specific configuration into Lua table represented as string
|
||||||
func locationConfigForLua(l, a interface{}) string {
|
func locationConfigForLua(l, a interface{}) string {
|
||||||
location, ok := l.(*ingress.Location)
|
location, ok := l.(*ingress.Location)
|
||||||
|
|
|
@ -4,7 +4,6 @@ local monitor = require("monitor")
|
||||||
local luaconfig = ngx.shared.luaconfig
|
local luaconfig = ngx.shared.luaconfig
|
||||||
local enablemetrics = luaconfig:get("enablemetrics")
|
local enablemetrics = luaconfig:get("enablemetrics")
|
||||||
|
|
||||||
|
|
||||||
balancer.log()
|
balancer.log()
|
||||||
|
|
||||||
if enablemetrics then
|
if enablemetrics then
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
ngx.exit(ngx.HTTP_NOT_FOUND)
|
|
|
@ -4,7 +4,6 @@ local redirect_to = ngx.arg[1]
|
||||||
local luaconfig = ngx.shared.luaconfig
|
local luaconfig = ngx.shared.luaconfig
|
||||||
local use_forwarded_headers = luaconfig:get("use_forwarded_headers")
|
local use_forwarded_headers = luaconfig:get("use_forwarded_headers")
|
||||||
|
|
||||||
|
|
||||||
if string.sub(request_uri, -1) == "/" then
|
if string.sub(request_uri, -1) == "/" then
|
||||||
request_uri = string.sub(request_uri, 1, -2)
|
request_uri = string.sub(request_uri, 1, -2)
|
||||||
end
|
end
|
||||||
|
@ -21,7 +20,5 @@ if use_forwarded_headers then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return string.format("%s://%s:%s%s", redirectScheme,
|
return string.format("%s://%s:%s%s", redirectScheme,
|
||||||
redirect_to, redirectPort, request_uri)
|
redirect_to, redirectPort, request_uri)
|
||||||
|
|
|
@ -147,8 +147,7 @@ function _M.is_blank(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _M.string_to_bool(str)
|
function _M.string_to_bool(str)
|
||||||
if str == "true" then return true end
|
return str == "true"
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- this implementation is taken from:
|
-- this implementation is taken from:
|
||||||
|
|
|
@ -679,7 +679,7 @@ http {
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
content_by_lua_file /etc/nginx/lua/nginx/ngx_not_found.lua;
|
return 404;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue