Skip to content

Commit

Permalink
update uuid reference
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Apr 28, 2024
1 parent f7d7a9c commit 9242242
Show file tree
Hide file tree
Showing 50 changed files with 94 additions and 80 deletions.
2 changes: 1 addition & 1 deletion kong/cluster_events/strategies/postgres.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local new_tab = require "table.new"


Expand Down
2 changes: 1 addition & 1 deletion kong/db/migrations/core/013_220_to_230.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local utils = require("kong.tools.utils")
local utils = require("kong.tools.uuid")


local CLUSTER_ID = utils.uuid()
Expand Down
3 changes: 2 additions & 1 deletion kong/db/schema/others/declarative_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local constants = require("kong.constants")
local plugin_loader = require("kong.db.schema.plugin_loader")
local vault_loader = require("kong.db.schema.vault_loader")
local schema_topological_sort = require("kong.db.schema.topological_sort")
local utils_uuid = require("kong.tools.uuid").uuid


local null = ngx.null
Expand Down Expand Up @@ -648,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] = utils.uuid()
item[pk_name] = utils_uuid()
end
end

Expand Down
3 changes: 2 additions & 1 deletion kong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ local wasm = require "kong.runloop.wasm"
local reports = require "kong.reports"
local pl_file = require "pl.file"
local req_dyn_hook = require "kong.dynamic_hook"
local uuid = require("kong.tools.uuid").uuid


local kong = kong
Expand Down Expand Up @@ -766,7 +767,7 @@ function Kong.init()
end

if config.request_debug and config.role ~= "control_plane" and is_http_module then
local token = config.request_debug_token or utils.uuid()
local token = config.request_debug_token or uuid()

local request_debug_token_file = pl_path.join(config.prefix,
constants.REQUEST_DEBUG_TOKEN_FILE)
Expand Down
9 changes: 5 additions & 4 deletions kong/pdk/node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
--
-- @module kong.node

local utils = require "kong.tools.utils"
local ffi = require "ffi"
local private_node = require "kong.pdk.private.node"
local uuid = require("kong.tools.uuid").uuid
local bytes_to_str = require("kong.tools.string").bytes_to_str


local floor = math.floor
Expand Down Expand Up @@ -46,7 +47,7 @@ local function convert_bytes(bytes, unit, scale)
return floor(bytes)
end

return utils.bytes_to_str(bytes, unit, scale)
return bytes_to_str(bytes, unit, scale)
end


Expand All @@ -73,7 +74,7 @@ local function new(self)

local shm = ngx.shared.kong

local ok, err = shm:safe_add(NODE_ID_KEY, utils.uuid())
local ok, err = shm:safe_add(NODE_ID_KEY, uuid())
if not ok and err ~= "exists" then
error("failed to set 'node_id' in shm: " .. err)
end
Expand Down Expand Up @@ -160,7 +161,7 @@ local function new(self)
unit = unit or "b"
scale = scale or 2

local pok, perr = pcall(utils.bytes_to_str, 0, unit, scale)
local pok, perr = pcall(bytes_to_str, 0, unit, scale)
if not pok then
error(perr, 2)
end
Expand Down
3 changes: 2 additions & 1 deletion kong/runloop/balancer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local pl_tablex = require "pl.tablex"
local utils = require "kong.tools.utils"
local hooks = require "kong.hooks"
local recreate_request = require("ngx.balancer").recreate_request
local uuid = require("kong.tools.uuid").uuid

local healthcheckers = require "kong.runloop.balancer.healthcheckers"
local balancers = require "kong.runloop.balancer.balancers"
Expand Down Expand Up @@ -145,7 +146,7 @@ local function get_value_to_hash(upstream, ctx)
ctx = ngx.ctx
end

identifier = utils.uuid()
identifier = uuid()

ctx.balancer_data.hash_cookie = {
key = upstream.hash_on_cookie,
Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/01-db/01-schema/07-plugins_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec.helpers" -- initializes 'kong' global for plugins
local Entity = require "kong.db.schema.entity"
local typedefs = require "kong.db.schema.typedefs"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local routes_definition = require "kong.db.schema.entities.routes"
local services_definition = require "kong.db.schema.entities.services"
local consumers_definition = require "kong.db.schema.entities.consumers"
Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/01-db/01-schema/11-snis_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local Schema = require "kong.db.schema"
local snis = require "kong.db.schema.entities.snis"
local certificates = require "kong.db.schema.entities.certificates"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"

Schema.new(certificates)
local Snis = assert(Schema.new(snis))
Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/09-balancer/01-generic_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local dnsA = function(...) return helpers.dnsA(client, ...) end
local dnsExpire = helpers.dnsExpire

local mocker = require "spec.fixtures.mocker"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"

local ws_id = utils.uuid()

Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/09-balancer/02-least_connections_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

local dns_utils = require "kong.resty.dns.utils"
local mocker = require "spec.fixtures.mocker"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"

local ws_id = utils.uuid()

Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/09-balancer/03-consistent_hashing_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local targets, balancers
require "spec.helpers" -- initialize db
local dns_utils = require "kong.resty.dns.utils"
local mocker = require "spec.fixtures.mocker"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"

local ws_id = utils.uuid()

Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/09-balancer/04-round_robin_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local targets, balancers

local dns_utils = require "kong.resty.dns.utils"
local mocker = require "spec.fixtures.mocker"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"

local ws_id = utils.uuid()

Expand Down
4 changes: 2 additions & 2 deletions spec/01-unit/09-balancer/05-worker_consistency_spec.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local utils = require "kong.tools.utils"
local utils = require "kong.tools.table"
local mocker = require "spec.fixtures.mocker"


local ws_id = utils.uuid()
local ws_id = require("kong.tools.uuid").uuid()


local function setup_it_block(consistency)
Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/09-balancer/06-latency_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

local dns_utils = require "kong.resty.dns.utils"
local mocker = require "spec.fixtures.mocker"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"

local ws_id = utils.uuid()

Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/14-dns_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local mocker = require "spec.fixtures.mocker"
local balancer = require "kong.runloop.balancer"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"

local ws_id = utils.uuid()

Expand Down
5 changes: 3 additions & 2 deletions spec/01-unit/27-queue_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local helpers = require "spec.helpers"
local mocker = require "spec.fixtures.mocker"
local timerng = require "resty.timerng"
local queue_schema = require "kong.tools.queue_schema"
local uuid = require("kong.tools.uuid").uuid
local queue_num = 1


Expand Down Expand Up @@ -70,7 +71,7 @@ describe("plugin queue", function()
err = function(message) return log('ERR', message) end,
},
plugin = {
get_id = function () return utils.uuid() end,
get_id = function () return uuid() end,
},
},
ngx = {
Expand Down Expand Up @@ -127,7 +128,7 @@ describe("plugin queue", function()

it("displays log_tag in log entries", function ()
local handler_invoked
local log_tag = utils.uuid()
local log_tag = uuid()
Queue.enqueue(
queue_conf({ name = "log-tag", log_tag = log_tag }),
function ()
Expand Down
2 changes: 1 addition & 1 deletion spec/02-integration/03-db/07-tags_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ for _, strategy in helpers.each_strategy() do
-- note this is different from test "update row in tags table with"
-- as this test actually creates new records
local scenarios = {
{ "upsert", { id = require("kong.tools.utils").uuid() }, { "service-upsert-1" } },
{ "upsert", { id = require("kong.tools.uuid").uuid() }, { "service-upsert-1" } },
{ "upsert_by_name", "service-upsert-2", { "service-upsert-2" } },
}
for _, scenario in pairs(scenarios) do
Expand Down
2 changes: 1 addition & 1 deletion spec/02-integration/03-db/10-db_unique_foreign_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local Errors = require "kong.db.errors"
local helpers = require "spec.helpers"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"


local fmt = string.format
Expand Down
3 changes: 2 additions & 1 deletion spec/02-integration/03-db/14-dao_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local helpers = require "spec.helpers"
local utils = require "kong.tools.utils"
local declarative = require "kong.db.declarative"
local uuid = require("kong.tools.uuid").uuid

-- Note: include "off" strategy here as well
for _, strategy in helpers.all_strategies() do
Expand Down Expand Up @@ -161,7 +162,7 @@ for _, strategy in helpers.all_strategies() do

-- new plugin upsert (insert part of upsert)
local new_plugin_config = {
id = utils.uuid(),
id = uuid(),
enabled = true,
name = "rate-limiting",
instance_name = 'rate-limiting-instance-2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local helpers = require "spec.helpers"
local cjson = require "cjson"
local escape = require("socket.url").escape
local Errors = require "kong.db.errors"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"


local function it_content_types(title, fn)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local helpers = require "spec.helpers"
local admin_api = require "spec.fixtures.admin_api"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local cjson = require "cjson"

for _, strategy in helpers.each_strategy() do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local ssl_fixtures = require "spec.fixtures.ssl"
local helpers = require "spec.helpers"
local cjson = require "cjson"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local Errors = require "kong.db.errors"


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local helpers = require "spec.helpers"
local cjson = require "cjson"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local tablex = require "pl.tablex"

local function it_content_types(title, fn)
Expand Down
2 changes: 1 addition & 1 deletion spec/02-integration/04-admin_api/09-routes_routes_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local cjson = require "cjson"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local helpers = require "spec.helpers"
local Errors = require "kong.db.errors"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local cjson = require "cjson"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local helpers = require "spec.helpers"
local Errors = require "kong.db.errors"

Expand Down
11 changes: 6 additions & 5 deletions spec/02-integration/04-admin_api/15-off_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local inspect = require "inspect"
local nkeys = require "table.nkeys"
local typedefs = require "kong.db.schema.typedefs"
local schema = require "kong.db.schema"
local uuid = require("kong.tools.uuid").uuid

local WORKER_SYNC_TIMEOUT = 10
local LMDB_MAP_SIZE = "10m"
Expand Down Expand Up @@ -83,7 +84,7 @@ describe("Admin API #off", function()
body = {
protocols = { "http" },
hosts = { "my.route.test" },
service = { id = utils.uuid() },
service = { id = uuid() },
},
headers = { ["Content-Type"] = content_type }
})
Expand All @@ -110,7 +111,7 @@ describe("Admin API #off", function()
methods = { "GET", "POST", "PATCH" },
hosts = { "foo.api.test", "bar.api.test" },
paths = { "/foo", "/bar" },
service = { id = utils.uuid() },
service = { id = uuid() },
},
headers = { ["Content-Type"] = content_type }
})
Expand Down Expand Up @@ -159,7 +160,7 @@ describe("Admin API #off", function()
path = "/routes",
body = {
paths = { "/" },
service = { id = utils.uuid() }
service = { id = uuid() }
},
headers = {
["Content-Type"] = "application/json"
Expand Down Expand Up @@ -187,10 +188,10 @@ describe("Admin API #off", function()
for i = 1, #methods do
local res = assert(client:send {
method = methods[i],
path = "/routes/" .. utils.uuid(),
path = "/routes/" .. uuid(),
body = {
paths = { "/" },
service = { id = utils.uuid() }
service = { id = uuid() }
},
headers = {
["Content-Type"] = "application/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local helpers = require "spec.helpers"
local cjson = require "cjson"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local Errors = require "kong.db.errors"


Expand Down
2 changes: 1 addition & 1 deletion spec/02-integration/04-admin_api/19-vaults_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local helpers = require "spec.helpers"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local cjson = require "cjson"


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local helpers = require "spec.helpers"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"
local cjson = require "cjson"
local pl_path = require "pl.path"
local pl_file = require "pl.file"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local bu = require "spec.fixtures.balancer_utils"
local cjson = require "cjson"
local helpers = require "spec.helpers"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"


local https_server = helpers.https_server
Expand Down
2 changes: 1 addition & 1 deletion spec/02-integration/05-proxy/14-server_tokens_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local meta = require "kong.meta"
local helpers = require "spec.helpers"
local constants = require "kong.constants"
local cjson = require "cjson"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"


local default_server_header = meta._SERVER_TOKENS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local cjson = require "cjson"
local helpers = require "spec.helpers"
local utils = require "kong.tools.utils"
local utils = require "kong.tools.uuid"


local POLL_INTERVAL = 0.3
Expand Down
Loading

0 comments on commit 9242242

Please sign in to comment.