Skip to content

Commit

Permalink
update and revert some reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Water-Melon committed May 16, 2024
1 parent 0a27d0e commit 3eecb25
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 40 deletions.
3 changes: 1 addition & 2 deletions kong/db/dao/targets.lua
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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 = {}
Expand Down
4 changes: 2 additions & 2 deletions kong/db/schema/others/declarative_config.lua
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions kong/db/strategies/postgres/connector.lua
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions kong/plugins/opentelemetry/otlp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion spec/01-unit/09-balancer/05-worker_consistency_spec.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions spec/01-unit/27-queue_spec.lua
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 ()
Expand Down
4 changes: 2 additions & 2 deletions spec/02-integration/03-db/14-dao_spec.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions spec/02-integration/09-hybrid_mode/01-sync_spec.lua
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
36 changes: 18 additions & 18 deletions spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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,
})
Expand Down Expand Up @@ -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)


--[[
Expand All @@ -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)


--[[
Expand All @@ -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 })
Expand All @@ -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 })
Expand All @@ -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 })
Expand All @@ -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 })
Expand All @@ -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 })
Expand All @@ -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 })
Expand All @@ -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 })
Expand All @@ -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 })
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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, {
Expand Down
Original file line number Diff line number Diff line change
@@ -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, {
Expand Down
3 changes: 2 additions & 1 deletion spec/03-plugins/29-acme/07-shorthand_fields_spec.lua
Original file line number Diff line number Diff line change
@@ -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, {
Expand Down

0 comments on commit 3eecb25

Please sign in to comment.