Skip to content

Commit

Permalink
[luacheck] Fix luacheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tkan145 committed Mar 5, 2024
1 parent e5f9e31 commit 2cd83c1
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 26 deletions.
3 changes: 1 addition & 2 deletions gateway/src/apicast/configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ local resty_url = require 'resty.url'
local util = require 'apicast.util'
local policy_chain = require 'apicast.policy_chain'
local mapping_rule = require 'apicast.mapping_rule'
local tab_new = require('resty.core.base').new_tab

local re = require 'ngx.re'
local match = ngx.re.match
Expand Down Expand Up @@ -67,7 +66,7 @@ local function build_policy_chain(policies)

local built_chain = policy_chain.new()
for i=1, #policies do
local ok, err = built_chain:add_policy(policies[i].name, policies[i].version, policies[i].configuration)
local _, err = built_chain:add_policy(policies[i].name, policies[i].version, policies[i].configuration)
if err then
ngx.log(ngx.WARN, 'failed to load policy: ', policies[i].name, ' version: ', policies[i].version, ' err: ', err)
end
Expand Down
1 change: 0 additions & 1 deletion gateway/src/apicast/configuration_loader/remote_v2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ function _M:index_custom_path(host)
return nil, 'not initialized'
end

local proxy_config_path = self.path
local env = resty_env.value('THREESCALE_DEPLOYMENT_ENV')

if not env then
Expand Down
2 changes: 0 additions & 2 deletions gateway/src/apicast/http_proxy.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
local format = string.format
local tostring = tostring
local ngx_flush = ngx.flush
local ngx_get_method = ngx.req.get_method
local ngx_http_version = ngx.req.http_version
local ngx_send_headers = ngx.send_headers

local resty_url = require "resty.url"
local url_helper = require('resty.url_helper')
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/apicast/management.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function _M.live()
end

local function context_configuration()
return executor:context().configuration or policy_loader:pcall("load_configuration", version or 'builtin')
return executor:context().configuration or policy_loader:pcall("load_configuration", 'builtin')
end

function _M.status(config)
Expand Down
1 change: 0 additions & 1 deletion gateway/src/apicast/policy/apicast/apicast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function _M:rewrite(context)
p:rewrite(service, context)
end

local err
context[self] = context[self] or {}
context[self].upstream, err = p.get_upstream(service, context)
context.get_upstream = function()
Expand Down
15 changes: 8 additions & 7 deletions gateway/src/apicast/policy/clear_context/clear_context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ function _M.new(...)
return new(...)
end

function _M:ssl_certificate(context)
--resetting the context after every other policy in the chain
--has executed their ssl_certificate phase.
clear_table(ngx.ctx)
end

function clear_table(t)
local function clear_table(t)
for k, _ in pairs(t) do
t[k] = nil
end
end

function _M:ssl_certificate(_)
--resetting the context after every other policy in the chain
--has executed their ssl_certificate phase.
clear_table(ngx.ctx)
end


return _M
2 changes: 1 addition & 1 deletion gateway/src/apicast/policy/ip_check/ip_check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function _M:access()
ngx.log(ngx.INFO, "Rejecting request due to is invalid to retrieve the IP information")
deny_request(self.error_msg)
return
end
end

self:check_client_ip(client_ip)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ local new = _M.new
local default_status_code = 503
local default_message = "Service Unavailable - Maintenance"
local default_message_content_type = "text/plain; charset=utf-8"
local default_template_type = 'plain'
local default_combine_op = "and"

local Condition = require('apicast.conditions.condition')
local Operation = require('apicast.conditions.operation')
Expand Down Expand Up @@ -49,7 +51,7 @@ function _M:load_condition(config)
self.condition = Condition.new( operations, config.condition.combine_op or default_combine_op)
end

function set_maintenance_mode(self)
local function set_maintenance_mode(self)
ngx.header['Content-Type'] = self.message_content_type
ngx.status = self.status_code
ngx.say(self.message)
Expand Down
2 changes: 0 additions & 2 deletions gateway/src/apicast/policy/upstream_mtls/upstream_mtls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ local function read_ca_certificates(ca_certificates)
if valid then
return store.store
end

store = nil
end

function _M.new(config)
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/apicast/policy/url_rewriting/url_rewriting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ end
function _M:rewrite(context)
for _, command in ipairs(self.commands) do
local should_apply_command = is_match_methods(command.methods)

if should_apply_command then
local rewritten = apply_rewrite_command(command)

Expand Down
1 change: 0 additions & 1 deletion gateway/src/apicast/usage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ local setmetatable = setmetatable
local ipairs = ipairs
local insert = table.insert
local remove = table.remove
local encode_args = ngx.encode_args
local tconcat = table.concat
local tinsert = table.insert
local format = string.format
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/resty/http/uri_escape.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function _M.escape_uri(source_uri)

local dst = ffi.new("unsigned char[?]", source_uri_len + 1 + tonumber(escape_len))
ngx_escape_uri(dst, source_str, source_uri_len, 0)
return ffi_str(dst)
return ffi_str(dst)
end

return _M
3 changes: 1 addition & 2 deletions gateway/src/resty/http_ng/headers.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
local insert = table.insert
local concat = table.concat
local assert = assert
local pairs = pairs
local rawset = rawset
local rawget = rawget
local setmetatable = setmetatable
Expand Down Expand Up @@ -78,7 +77,7 @@ end

headers.normalize = function(http_headers)
http_headers = http_headers or {}

local serialize = function(k,v)
return headers.normalize_value(v), headers.normalize_key(k)
end
Expand Down
2 changes: 0 additions & 2 deletions gateway/src/resty/http_ng/request.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local find = string.find
local sub = string.sub
local assert = assert
local setmetatable = setmetatable
local resty_url = require 'resty.url'
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/resty/openssl/x509/store.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function _M.new()
local verify_param = X509_VERIFY_PARAM(X509_V_FLAG_PARTIAL_CHAIN)

ffi_assert(C.X509_STORE_set1_param(store, verify_param),1)

local self = setmetatable({
store = store,
}, mt)
Expand Down

0 comments on commit 2cd83c1

Please sign in to comment.