From a321ebfd2f18c0e57e2dcf0de27e381679c56cba Mon Sep 17 00:00:00 2001 From: chronolaw Date: Wed, 5 Jun 2024 11:17:39 +0800 Subject: [PATCH 1/4] file-log/handler.lua --- kong/plugins/file-log/handler.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/kong/plugins/file-log/handler.lua b/kong/plugins/file-log/handler.lua index 2b27622293c7..c7d4fe9a1954 100644 --- a/kong/plugins/file-log/handler.lua +++ b/kong/plugins/file-log/handler.lua @@ -1,5 +1,4 @@ -- Copyright (C) Kong Inc. -require "kong.tools.utils" -- ffi.cdefs local kong_meta = require "kong.meta" From 3b432061a15701d182d6700f3bbc5b23ecaebc38 Mon Sep 17 00:00:00 2001 From: chronolaw Date: Wed, 5 Jun 2024 11:19:51 +0800 Subject: [PATCH 2/4] spec/helpers.lua --- spec/helpers.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/helpers.lua b/spec/helpers.lua index 57b9fea00da3..5cedb14fee35 100644 --- a/spec/helpers.lua +++ b/spec/helpers.lua @@ -695,7 +695,7 @@ end -- @param opts table with options. See [lua-resty-http](https://github.com/pintsized/lua-resty-http) function resty_http_proxy_mt:send(opts, is_reopen) local cjson = require "cjson" - local utils = require "kong.tools.utils" + local encode_args = require("kong.tools.http").encode_args opts = opts or {} @@ -709,7 +709,7 @@ function resty_http_proxy_mt:send(opts, is_reopen) opts.body = cjson.encode(opts.body) elseif string.find(content_type, "www-form-urlencoded", nil, true) and t_body_table then - opts.body = utils.encode_args(opts.body, true, opts.no_array_indexes) + opts.body = encode_args(opts.body, true, opts.no_array_indexes) elseif string.find(content_type, "multipart/form-data", nil, true) and t_body_table then local form = opts.body @@ -738,7 +738,7 @@ function resty_http_proxy_mt:send(opts, is_reopen) -- build querystring (assumes none is currently in 'opts.path') if type(opts.query) == "table" then - local qs = utils.encode_args(opts.query) + local qs = encode_args(opts.query) opts.path = opts.path .. "?" .. qs opts.query = nil end From 2e65fc22460765504ce382f1fe6ab9d9606093f2 Mon Sep 17 00:00:00 2001 From: chronolaw Date: Wed, 5 Jun 2024 11:23:19 +0800 Subject: [PATCH 3/4] utils.lua --- kong/tools/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kong/tools/utils.lua b/kong/tools/utils.lua index b7cff5add1e5..4b958d90fe79 100644 --- a/kong/tools/utils.lua +++ b/kong/tools/utils.lua @@ -24,9 +24,9 @@ do "kong.tools.rand", "kong.tools.time", "kong.tools.string", - -- ]] keep it here for compatibility "kong.tools.ip", "kong.tools.http", + -- ]] keep it here for compatibility } for _, str in ipairs(modules) do From 0bed5ccace55cf11a0907f1856f586cdbb4ae73f Mon Sep 17 00:00:00 2001 From: chronolaw Date: Wed, 5 Jun 2024 11:29:16 +0800 Subject: [PATCH 4/4] shallow_copy for upgrade test --- spec/helpers/http_mock/nginx_instance.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/helpers/http_mock/nginx_instance.lua b/spec/helpers/http_mock/nginx_instance.lua index f27917bd5ba2..50b926ef9944 100644 --- a/spec/helpers/http_mock/nginx_instance.lua +++ b/spec/helpers/http_mock/nginx_instance.lua @@ -14,9 +14,16 @@ local error = error local assert = assert local ngx = ngx local io = io --- It can't be changed to kong.tools.table because the old version --- does not have kong/tools/table.lua, so the upgrade test will fail. -local shallow_copy = require("kong.tools.utils").shallow_copy + +local shallow_copy +do + local clone = require "table.clone" + + shallow_copy = function(orig) + assert(type(orig) == "table") + return clone(orig) + end +end local template = assert(pl_template.compile(template_str)) local render_env = {ipairs = ipairs, pairs = pairs, error = error, }