From 3eecb25f5c224dc3c90f72207ad51579009d64c6 Mon Sep 17 00:00:00 2001 From: Water-Melon Date: Thu, 16 May 2024 07:09:12 +0000 Subject: [PATCH] update and revert some reference --- kong/db/dao/targets.lua | 3 +- kong/db/schema/others/declarative_config.lua | 4 +-- kong/db/strategies/postgres/connector.lua | 3 +- kong/plugins/opentelemetry/otlp.lua | 3 +- .../05-worker_consistency_spec.lua | 3 +- spec/01-unit/27-queue_spec.lua | 6 ++-- spec/02-integration/03-db/14-dao_spec.lua | 4 +-- .../09-hybrid_mode/01-sync_spec.lua | 6 ++-- .../09-hybrid_mode/09-config-compat_spec.lua | 36 +++++++++---------- .../01-header_transformer_spec.lua | 4 +-- .../06-shorthand_fields_spec.lua | 3 +- .../06-shorthand_fields_spec.lua | 3 +- .../29-acme/07-shorthand_fields_spec.lua | 3 +- 13 files changed, 41 insertions(+), 40 deletions(-) diff --git a/kong/db/dao/targets.lua b/kong/db/dao/targets.lua index af04f0324c44..09077ec670b2 100644 --- a/kong/db/dao/targets.lua +++ b/kong/db/dao/targets.lua @@ -1,6 +1,5 @@ local balancer = require "kong.runloop.balancer" local utils = require "kong.tools.utils" -local kong_table = require "kong.tools.table" local cjson = require "cjson" local workspaces = require "kong.workspaces" @@ -11,7 +10,7 @@ local ipairs = ipairs local table = table local type = type local min = math.min -local table_merge = kong_table.table_merge +local table_merge = require("kong.tools.table").table_merge local _TARGETS = {} diff --git a/kong/db/schema/others/declarative_config.lua b/kong/db/schema/others/declarative_config.lua index 105da9be8e78..48c8704c44d5 100644 --- a/kong/db/schema/others/declarative_config.lua +++ b/kong/db/schema/others/declarative_config.lua @@ -1,5 +1,5 @@ local uuid = require("resty.jit-uuid") -local kong_uuid = require("kong.tools.uuid").uuid +local utils = require("kong.tools.utils") local kong_table = require("kong.tools.table") local Errors = require("kong.db.errors") local Entity = require("kong.db.schema.entity") @@ -649,7 +649,7 @@ local function populate_ids_for_validation(input, known_entities, parent_entity, if key then item[pk_name] = generate_uuid(schema.name, key) else - item[pk_name] = kong_uuid() + item[pk_name] = utils.uuid() end end diff --git a/kong/db/strategies/postgres/connector.lua b/kong/db/strategies/postgres/connector.lua index 33b9e2df05c2..12559403ef58 100644 --- a/kong/db/strategies/postgres/connector.lua +++ b/kong/db/strategies/postgres/connector.lua @@ -1,5 +1,4 @@ local logger = require "kong.cmd.utils.log" -local kong_table = require "kong.tools.table" local pgmoon = require "pgmoon" local arrays = require "pgmoon.arrays" local stringx = require "pl.stringx" @@ -31,7 +30,7 @@ local fmt = string.format local sub = string.sub local utils_toposort = db_utils.topological_sort local insert = table.insert -local table_merge = kong_table.table_merge +local table_merge = require("kong.tools.table").table_merge local WARN = ngx.WARN diff --git a/kong/plugins/opentelemetry/otlp.lua b/kong/plugins/opentelemetry/otlp.lua index 7c3e46791c6a..649b427c26d0 100644 --- a/kong/plugins/opentelemetry/otlp.lua +++ b/kong/plugins/opentelemetry/otlp.lua @@ -4,13 +4,12 @@ local new_tab = require "table.new" local nkeys = require "table.nkeys" local tablepool = require "tablepool" local cycle_aware_deep_copy = require("kong.tools.table").cycle_aware_deep_copy -local kong_table = require "kong.tools.table" local kong = kong local insert = table.insert local tablepool_fetch = tablepool.fetch local tablepool_release = tablepool.release -local table_merge = kong_table.table_merge +local table_merge = require("kong.tools.table").table_merge local setmetatable = setmetatable local TRACE_ID_LEN = 16 diff --git a/spec/01-unit/09-balancer/05-worker_consistency_spec.lua b/spec/01-unit/09-balancer/05-worker_consistency_spec.lua index 3dd7d3714358..18784b4690c8 100644 --- a/spec/01-unit/09-balancer/05-worker_consistency_spec.lua +++ b/spec/01-unit/09-balancer/05-worker_consistency_spec.lua @@ -1,8 +1,9 @@ +local utils = require "kong.tools.utils" local mocker = require "spec.fixtures.mocker" local cycle_aware_deep_copy = require("kong.tools.table").cycle_aware_deep_copy -local ws_id = require("kong.tools.uuid").uuid() +local ws_id = utils.uuid() local function setup_it_block(consistency) diff --git a/spec/01-unit/27-queue_spec.lua b/spec/01-unit/27-queue_spec.lua index 45717eb6c104..878d0f85892f 100644 --- a/spec/01-unit/27-queue_spec.lua +++ b/spec/01-unit/27-queue_spec.lua @@ -1,6 +1,6 @@ local Queue = require "kong.tools.queue" local cycle_aware_deep_copy = require("kong.tools.table").cycle_aware_deep_copy -local uuid = require("kong.tools.uuid").uuid +local utils = require "kong.tools.utils" local helpers = require "spec.helpers" local mocker = require "spec.fixtures.mocker" local timerng = require "resty.timerng" @@ -71,7 +71,7 @@ describe("plugin queue", function() err = function(message) return log('ERR', message) end, }, plugin = { - get_id = function () return uuid() end, + get_id = function () return utils.uuid() end, }, }, ngx = { @@ -128,7 +128,7 @@ describe("plugin queue", function() it("displays log_tag in log entries", function () local handler_invoked - local log_tag = uuid() + local log_tag = utils.uuid() Queue.enqueue( queue_conf({ name = "log-tag", log_tag = log_tag }), function () diff --git a/spec/02-integration/03-db/14-dao_spec.lua b/spec/02-integration/03-db/14-dao_spec.lua index b989626400e1..d71d59dc1bac 100644 --- a/spec/02-integration/03-db/14-dao_spec.lua +++ b/spec/02-integration/03-db/14-dao_spec.lua @@ -1,6 +1,6 @@ local helpers = require "spec.helpers" +local utils = require "kong.tools.utils" local declarative = require "kong.db.declarative" -local uuid = require("kong.tools.uuid").uuid local cycle_aware_deep_copy = require("kong.tools.table").cycle_aware_deep_copy -- Note: include "off" strategy here as well @@ -162,7 +162,7 @@ for _, strategy in helpers.all_strategies() do -- new plugin upsert (insert part of upsert) local new_plugin_config = { - id = uuid(), + id = utils.uuid(), enabled = true, name = "rate-limiting", instance_name = 'rate-limiting-instance-2', diff --git a/spec/02-integration/09-hybrid_mode/01-sync_spec.lua b/spec/02-integration/09-hybrid_mode/01-sync_spec.lua index a0d6232da216..0573be38d667 100644 --- a/spec/02-integration/09-hybrid_mode/01-sync_spec.lua +++ b/spec/02-integration/09-hybrid_mode/01-sync_spec.lua @@ -1,11 +1,11 @@ local helpers = require "spec.helpers" +local utils = require "kong.tools.utils" local cjson = require "cjson.safe" local _VERSION_TABLE = require "kong.meta" ._VERSION_TABLE local MAJOR = _VERSION_TABLE.major local MINOR = _VERSION_TABLE.minor local PATCH = _VERSION_TABLE.patch local CLUSTERING_SYNC_STATUS = require("kong.constants").CLUSTERING_SYNC_STATUS -local uuid = require("kong.tools.uuid").uuid local cycle_aware_deep_copy = require("kong.tools.table").cycle_aware_deep_copy @@ -480,7 +480,7 @@ describe("CP/DP #version check #" .. strategy, function() for desc, harness in pairs(allowed_cases) do it(desc .. ", sync is allowed", function() - local uuid = uuid() + local uuid = utils.uuid() local res = assert(helpers.clustering_client({ host = "127.0.0.1", @@ -567,7 +567,7 @@ describe("CP/DP #version check #" .. strategy, function() for desc, harness in pairs(blocked_cases) do it(desc ..", sync is blocked", function() - local uuid = uuid() + local uuid = utils.uuid() local res, err = helpers.clustering_client({ host = "127.0.0.1", diff --git a/spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua b/spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua index 565c1da37594..1c8f7bd26ee5 100644 --- a/spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua +++ b/spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua @@ -1,7 +1,7 @@ local helpers = require "spec.helpers" +local utils = require "kong.tools.utils" local cjson = require "cjson" local CLUSTERING_SYNC_STATUS = require("kong.constants").CLUSTERING_SYNC_STATUS -local uuid = require("kong.tools.uuid").uuid local cycle_aware_deep_copy = require("kong.tools.table").cycle_aware_deep_copy local admin = require "spec.fixtures.admin_api" @@ -20,7 +20,7 @@ local function cluster_client(opts) cert = "spec/fixtures/kong_clustering.crt", cert_key = "spec/fixtures/kong_clustering.key", node_hostname = opts.hostname or "test", - node_id = opts.id or uuid(), + node_id = opts.id or utils.uuid(), node_version = opts.version, node_plugins_list = PLUGIN_LIST, }) @@ -142,7 +142,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected.config.error_code = nil expected.config.error_message = nil expected.config.sync_rate = nil - do_assert(uuid(), "3.0.0", expected) + do_assert(utils.uuid(), "3.0.0", expected) --[[ @@ -153,7 +153,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected = cycle_aware_deep_copy(rate_limit) expected.config.redis = nil expected.config.sync_rate = nil - do_assert(uuid(), "3.2.0", expected) + do_assert(utils.uuid(), "3.2.0", expected) --[[ @@ -164,7 +164,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected = cycle_aware_deep_copy(rate_limit) expected.config.redis = nil expected.config.sync_rate = nil - do_assert(uuid(), "3.3.0", expected) + do_assert(utils.uuid(), "3.3.0", expected) -- cleanup admin.plugins:remove({ id = rate_limit.id }) @@ -191,7 +191,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() local expected = cycle_aware_deep_copy(rate_limit) expected.config.redis = nil - do_assert(uuid(), "3.4.0", expected) + do_assert(utils.uuid(), "3.4.0", expected) -- cleanup admin.plugins:remove({ id = rate_limit.id }) @@ -212,7 +212,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() assert.not_nil(cors.config.private_network) local expected_cors = cycle_aware_deep_copy(cors) expected_cors.config.private_network = nil - do_assert(uuid(), "3.4.0", expected_cors) + do_assert(utils.uuid(), "3.4.0", expected_cors) -- cleanup admin.plugins:remove({ id = cors.id }) @@ -228,7 +228,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() -- ]] } } - do_assert(uuid(), "3.5.0", cors) + do_assert(utils.uuid(), "3.5.0", cors) -- cleanup admin.plugins:remove({ id = cors.id }) @@ -253,7 +253,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected_otel_prior_35.config.header_type = "preserve" expected_otel_prior_35.config.sampling_rate = nil expected_otel_prior_35.config.propagation = nil - do_assert(uuid(), "3.4.0", expected_otel_prior_35) + do_assert(utils.uuid(), "3.4.0", expected_otel_prior_35) -- cleanup admin.plugins:remove({ id = opentelemetry.id }) @@ -274,7 +274,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected_otel_prior_34.config.header_type = "preserve" expected_otel_prior_34.config.sampling_rate = nil expected_otel_prior_34.config.propagation = nil - do_assert(uuid(), "3.3.0", expected_otel_prior_34) + do_assert(utils.uuid(), "3.3.0", expected_otel_prior_34) -- cleanup admin.plugins:remove({ id = opentelemetry.id }) @@ -300,7 +300,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected_zipkin_prior_35.config.header_type = "preserve" expected_zipkin_prior_35.config.default_header_type = "b3" expected_zipkin_prior_35.config.propagation = nil - do_assert(uuid(), "3.4.0", expected_zipkin_prior_35) + do_assert(utils.uuid(), "3.4.0", expected_zipkin_prior_35) -- cleanup admin.plugins:remove({ id = zipkin.id }) @@ -321,7 +321,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected_zipkin_prior_34.config.header_type = "preserve" expected_zipkin_prior_34.config.default_header_type = "b3" expected_zipkin_prior_34.config.propagation = nil - do_assert(uuid(), "3.3.0", expected_zipkin_prior_34) + do_assert(utils.uuid(), "3.3.0", expected_zipkin_prior_34) -- cleanup admin.plugins:remove({ id = zipkin.id }) @@ -372,7 +372,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() namespace = "test_namespace", scan_count = 13 } - do_assert(uuid(), "3.5.0", expected_acme_prior_36) + do_assert(utils.uuid(), "3.5.0", expected_acme_prior_36) -- cleanup admin.plugins:remove({ id = acme.id }) @@ -417,7 +417,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected_rl_prior_36.config.redis_server_name = "example.test" - do_assert(uuid(), "3.5.0", expected_rl_prior_36) + do_assert(utils.uuid(), "3.5.0", expected_rl_prior_36) -- cleanup admin.plugins:remove({ id = rl.id }) @@ -466,7 +466,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected_response_rl_prior_36.config.redis_server_name = "example.test" - do_assert(uuid(), "3.5.0", expected_response_rl_prior_36) + do_assert(utils.uuid(), "3.5.0", expected_response_rl_prior_36) -- cleanup admin.plugins:remove({ id = response_rl.id }) @@ -505,7 +505,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() expected_ai_proxy_prior_37.config.model.options.upstream_path = nil expected_ai_proxy_prior_37.config.route_type = "llm/v1/chat" - do_assert(uuid(), "3.6.0", expected_ai_proxy_prior_37) + do_assert(utils.uuid(), "3.6.0", expected_ai_proxy_prior_37) -- cleanup admin.plugins:remove({ id = ai_proxy.id }) @@ -544,7 +544,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() local expected_ai_request_transformer_prior_37 = cycle_aware_deep_copy(ai_request_transformer) expected_ai_request_transformer_prior_37.config.llm.model.options.upstream_path = nil - do_assert(uuid(), "3.6.0", expected_ai_request_transformer_prior_37) + do_assert(utils.uuid(), "3.6.0", expected_ai_request_transformer_prior_37) -- cleanup admin.plugins:remove({ id = ai_request_transformer.id }) @@ -581,7 +581,7 @@ describe("CP/DP config compat transformations #" .. strategy, function() local expected_ai_response_transformer_prior_37 = cycle_aware_deep_copy(ai_response_transformer) expected_ai_response_transformer_prior_37.config.llm.model.options.upstream_path = nil - do_assert(uuid(), "3.6.0", expected_ai_response_transformer_prior_37) + do_assert(utils.uuid(), "3.6.0", expected_ai_response_transformer_prior_37) -- cleanup admin.plugins:remove({ id = ai_response_transformer.id }) diff --git a/spec/03-plugins/15-response-transformer/01-header_transformer_spec.lua b/spec/03-plugins/15-response-transformer/01-header_transformer_spec.lua index 71fc23fed876..4aa1595f5f75 100644 --- a/spec/03-plugins/15-response-transformer/01-header_transformer_spec.lua +++ b/spec/03-plugins/15-response-transformer/01-header_transformer_spec.lua @@ -25,11 +25,11 @@ describe("Plugin: response-transformer", function() headers_sent = false, resp = { }, - config = ngx.config, + config = ngx.config, -- jit-uuid needs ngx.config.nginx_configure ctx = { KONG_PHASE = 0x00000200, }, - re = ngx.re, + re = ngx.re, -- jit-uuid will use ngx.re.find } _G.ngx.DEBUG = 8 diff --git a/spec/03-plugins/23-rate-limiting/06-shorthand_fields_spec.lua b/spec/03-plugins/23-rate-limiting/06-shorthand_fields_spec.lua index 75724bffa6c9..d5c122fb62a8 100644 --- a/spec/03-plugins/23-rate-limiting/06-shorthand_fields_spec.lua +++ b/spec/03-plugins/23-rate-limiting/06-shorthand_fields_spec.lua @@ -1,10 +1,11 @@ local helpers = require "spec.helpers" +local utils = require "kong.tools.utils" local cjson = require "cjson" describe("Plugin: rate-limiting (shorthand fields)", function() local bp, route, admin_client - local plugin_id = require("kong.tools.uuid").uuid() + local plugin_id = utils.uuid() lazy_setup(function() bp = helpers.get_db_utils(nil, { diff --git a/spec/03-plugins/24-response-rate-limiting/06-shorthand_fields_spec.lua b/spec/03-plugins/24-response-rate-limiting/06-shorthand_fields_spec.lua index a5875ac7af9d..69275b322887 100644 --- a/spec/03-plugins/24-response-rate-limiting/06-shorthand_fields_spec.lua +++ b/spec/03-plugins/24-response-rate-limiting/06-shorthand_fields_spec.lua @@ -1,10 +1,11 @@ local helpers = require "spec.helpers" +local utils = require "kong.tools.utils" local cjson = require "cjson" describe("Plugin: response-ratelimiting (shorthand fields)", function() local bp, route, admin_client - local plugin_id = require("kong.tools.uuid").uuid() + local plugin_id = utils.uuid() lazy_setup(function() bp = helpers.get_db_utils(nil, { diff --git a/spec/03-plugins/29-acme/07-shorthand_fields_spec.lua b/spec/03-plugins/29-acme/07-shorthand_fields_spec.lua index a2d4b236ffd5..f40b47f9af6f 100644 --- a/spec/03-plugins/29-acme/07-shorthand_fields_spec.lua +++ b/spec/03-plugins/29-acme/07-shorthand_fields_spec.lua @@ -1,10 +1,11 @@ local helpers = require "spec.helpers" +local utils = require "kong.tools.utils" local cjson = require "cjson" describe("Plugin: acme (shorthand fields)", function() local bp, route, admin_client - local plugin_id = require("kong.tools.uuid").uuid() + local plugin_id = utils.uuid() lazy_setup(function() bp = helpers.get_db_utils(nil, {