Skip to content

Commit

Permalink
use proper uuid module name
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Apr 29, 2024
1 parent a3acbe9 commit eccff0c
Show file tree
Hide file tree
Showing 47 changed files with 188 additions and 188 deletions.
6 changes: 3 additions & 3 deletions kong/api/endpoints.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local Errors = require "kong.db.errors"
local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"
local arguments = require "kong.api.arguments"
local workspaces = require "kong.workspaces"
local app_helpers = require "lapis.application"
Expand Down Expand Up @@ -242,7 +242,7 @@ local function query_entity(context, self, db, schema, method)
end
end

if key.id and not utils.is_valid_uuid(key.id) then
if key.id and not uuid.is_valid_uuid(key.id) then
local endpoint_key = schema.endpoint_key
if endpoint_key then
local field = schema.fields[endpoint_key]
Expand Down Expand Up @@ -527,7 +527,7 @@ local function put_entity_endpoint(schema, foreign_schema, foreign_field_name, m
self.params[foreign_schema.name] = pk
else
associate = true
self.params[foreign_schema.name] = utils.uuid()
self.params[foreign_schema.name] = uuid.uuid()
end

else
Expand Down
6 changes: 3 additions & 3 deletions kong/api/routes/certificates.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local endpoints = require "kong.api.endpoints"
local arguments = require "kong.api.arguments"
local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"


local ngx = ngx
Expand All @@ -15,7 +15,7 @@ local function prepare_params(self)
local id = unescape_uri(self.params.certificates)
local method = self.req.method
local name
if not utils.is_valid_uuid(id) then
if not uuid.is_valid_uuid(id) then
name = arguments.infer_value(id, kong.db.snis.schema.fields.name)

local sni, _, err_t = kong.db.snis:select_by_name(name)
Expand All @@ -31,7 +31,7 @@ local function prepare_params(self)
return kong.response.exit(404, { message = "SNI not found" })
end

id = utils.uuid()
id = uuid.uuid()
end
end

Expand Down
6 changes: 3 additions & 3 deletions kong/api/routes/upstreams.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local endpoints = require "kong.api.endpoints"
local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"


local kong = kong
Expand All @@ -21,7 +21,7 @@ local function set_target_health(self, db, is_healthy)
end

local target
if utils.is_valid_uuid(unescape_uri(self.params.targets)) then
if uuid.is_valid_uuid(unescape_uri(self.params.targets)) then
target, _, err_t = endpoints.select_entity(self, db, db.targets.schema)

else
Expand Down Expand Up @@ -90,7 +90,7 @@ local function target_endpoint(self, db, callback)
end

local target
if utils.is_valid_uuid(unescape_uri(self.params.targets)) then
if uuid.is_valid_uuid(unescape_uri(self.params.targets)) then
target, _, err_t = endpoints.select_entity(self, db, db.targets.schema)

else
Expand Down
4 changes: 2 additions & 2 deletions 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.uuid"
local uuid = require "kong.tools.uuid"
local new_tab = require "table.new"


Expand Down Expand Up @@ -97,7 +97,7 @@ function _M:insert(node_id, channel, at, data, delay)
nbf = "NULL"
end

local pg_id = self.connector:escape_literal(utils.uuid())
local pg_id = self.connector:escape_literal(uuid.uuid())
local pg_node_id = self.connector:escape_literal(node_id)
local pg_channel = self.connector:escape_literal(channel)
local pg_data = self.connector:escape_literal(data)
Expand Down
4 changes: 2 additions & 2 deletions kong/db/errors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local pl_pretty = require("pl.pretty").write
local pl_keys = require("pl.tablex").keys
local nkeys = require("table.nkeys")
local table_isarray = require("table.isarray")
local utils = require("kong.tools.uuid")
local uuid = require("kong.tools.uuid")


local type = type
Expand Down Expand Up @@ -757,7 +757,7 @@ do
---@return string|nil
local function validate_id(id)
return (type(id) == "string"
and utils.is_valid_uuid(id)
and uuid.is_valid_uuid(id)
and id)
or nil
end
Expand Down
4 changes: 2 additions & 2 deletions kong/db/migrations/core/013_220_to_230.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local utils = require("kong.tools.uuid")
local uuid = require("kong.tools.uuid")


local CLUSTER_ID = utils.uuid()
local CLUSTER_ID = uuid.uuid()


return {
Expand Down
8 changes: 4 additions & 4 deletions kong/pdk/private/node.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local log = require "kong.cmd.utils.log"
local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"
local pl_file = require "pl.file"
local pl_path = require "pl.path"
local pl_dir = require "pl.dir"
Expand Down Expand Up @@ -31,15 +31,15 @@ local function initialize_node_id(prefix)
return nil, fmt("failed to access file %s: %s", filename, err)
end

if not utils.is_valid_uuid(id) then
if not uuid.is_valid_uuid(id) then
log.debug("file %s contains invalid uuid: %s", filename, id)
-- set false to override it when it contains an invalid uuid.
file_exists = false
end
end

if not file_exists then
local id = utils.uuid()
local id = uuid.uuid()
log.debug("persisting node_id (%s) to %s", id, filename)

local ok, write_err = pl_file.write(filename, id)
Expand Down Expand Up @@ -89,7 +89,7 @@ local function load_node_id(prefix)
return nil, fmt("failed to access file %s: %s", filename, read_err)
end

if not utils.is_valid_uuid(id) then
if not uuid.is_valid_uuid(id) then
return nil, fmt("file %s contains invalid uuid: %q", filename, id)
end

Expand Down
8 changes: 4 additions & 4 deletions kong/plugins/acl/api.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local endpoints = require "kong.api.endpoints"
local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"


local ngx = ngx
Expand All @@ -13,10 +13,10 @@ return {
schema = kong.db.acls.schema,
before = function(self, db, helpers)
local group = unescape_uri(self.params.acls)
if not utils.is_valid_uuid(group) then
if not uuid.is_valid_uuid(group) then
local consumer_id = unescape_uri(self.params.consumers)

if not utils.is_valid_uuid(consumer_id) then
if not uuid.is_valid_uuid(consumer_id) then
local consumer, _, err_t = endpoints.select_entity(self, db, db.consumers.schema)
if err_t then
return endpoints.handle_error(err_t)
Expand All @@ -42,7 +42,7 @@ return {
return kong.response.error(404)
end

self.params.acls = utils.uuid()
self.params.acls = uuid.uuid()
end

self.params.group = group
Expand Down
4 changes: 2 additions & 2 deletions kong/runloop/wasm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local _M = {
---@field config_schema kong.db.schema.json.schema_doc|nil


local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"
local reports = require "kong.reports"
local clear_tab = require "table.clear"
local cjson = require "cjson.safe"
Expand Down Expand Up @@ -81,7 +81,7 @@ local FILTER_META_SCHEMA = {
--
---@return string
local function get_version()
return kong.core_cache:get(VERSION_KEY, TTL_ZERO, utils.uuid)
return kong.core_cache:get(VERSION_KEY, TTL_ZERO, uuid.uuid)
end


Expand Down
22 changes: 11 additions & 11 deletions 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.uuid"
local uuid = 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 Expand Up @@ -78,7 +78,7 @@ describe("plugins", function()
-- Success
local plugin = {
name = "key-auth",
service = { id = utils.uuid() },
service = { id = uuid.uuid() },
config = {
key_names = { "x-kong-key" }
}
Expand All @@ -91,7 +91,7 @@ describe("plugins", function()
-- Failure
plugin = {
name = "rate-limiting",
service = { id = utils.uuid() },
service = { id = uuid.uuid() },
config = {
second = "hello"
}
Expand All @@ -112,7 +112,7 @@ describe("plugins", function()
-- Insert key-auth, whose config has some default values that should be set
local plugin = {
name = "key-auth",
service = { id = utils.uuid() },
service = { id = uuid.uuid() },
}
plugin = Plugins:process_auto_fields(plugin)
local ok = Plugins:validate(plugin)
Expand All @@ -133,7 +133,7 @@ describe("plugins", function()
-- Insert response-transformer, whose default config has no default values, and should be empty
local plugin = {
name = "response-transformer",
service = { id = utils.uuid() },
service = { id = uuid.uuid() },
}
plugin = Plugins:process_auto_fields(plugin)
local ok = Plugins:validate(plugin)
Expand Down Expand Up @@ -182,7 +182,7 @@ describe("plugins", function()

local ok, err = Plugins:validate(Plugins:process_auto_fields({
name = "with-no-route",
route = { id = utils.uuid() },
route = { id = uuid.uuid() },
config = {
string = "foo",
}
Expand Down Expand Up @@ -219,7 +219,7 @@ describe("plugins", function()

local ok, err = Plugins:validate(Plugins:process_auto_fields({
name = "with-no-service",
service = { id = utils.uuid() },
service = { id = uuid.uuid() },
config = {
string = "foo",
}
Expand Down Expand Up @@ -256,7 +256,7 @@ describe("plugins", function()

local ok, err = Plugins:validate(Plugins:process_auto_fields({
name = "with-no-consumer",
consumer = { id = utils.uuid() },
consumer = { id = uuid.uuid() },
config = {
string = "foo",
}
Expand All @@ -279,21 +279,21 @@ describe("plugins", function()
it("accepts a plugin if configured for route", function()
assert(Plugins:validate(Plugins:process_auto_fields({
name = "key-auth",
route = { id = utils.uuid() },
route = { id = uuid.uuid() },
})))
end)

it("accepts a plugin if configured for service", function()
assert(Plugins:validate(Plugins:process_auto_fields({
name = "key-auth",
service = { id = utils.uuid() },
service = { id = uuid.uuid() },
})))
end)

it("accepts a plugin if configured for consumer", function()
assert(Plugins:validate(Plugins:process_auto_fields({
name = "rate-limiting",
consumer = { id = utils.uuid() },
consumer = { id = uuid.uuid() },
config = {
second = 1,
}
Expand Down
4 changes: 2 additions & 2 deletions spec/01-unit/01-db/01-schema/08-targets_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local Schema = require "kong.db.schema"
local targets = require "kong.db.schema.entities.targets"
local certificates = require "kong.db.schema.entities.certificates"
local upstreams = require "kong.db.schema.entities.upstreams"
local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"

local function setup_global_env()
_G.kong = _G.kong or {}
Expand Down Expand Up @@ -32,7 +32,7 @@ describe("targets", function()
setup_global_env()
describe("targets.target", function()
it("validates", function()
local upstream = { id = utils.uuid() }
local upstream = { id = uuid.uuid() }
local targets = { "valid.name", "valid.name:8080", "12.34.56.78", "1.2.3.4:123" }
for _, target in ipairs(targets) do
local ok, err = validate({ target = target, upstream = upstream })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local helpers = require "spec.helpers"
local lyaml = require "lyaml"
local cjson = require "cjson"
local tablex = require "pl.tablex"
local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"

local null = ngx.null

Expand Down Expand Up @@ -48,7 +48,7 @@ local function idempotent(tbl, err)
local function recurse_fields(t)
helpers.deep_sort(t)
for k,v in sortedpairs(t) do
if k == "id" and utils.is_valid_uuid(v) then
if k == "id" and uuid.is_valid_uuid(v) then
t[k] = "UUID"
end
if k == "client_id" or k == "client_secret" or k == "access_token" then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local null = ngx.null

local helpers = require "spec.helpers"
local tablex = require "pl.tablex"
local utils = require "kong.tools.uuid"
local uuid = require "kong.tools.uuid"

local function sort_by_key(t)
return function(a, b)
Expand Down Expand Up @@ -48,7 +48,7 @@ local function idempotent(tbl, err)
local function recurse_fields(t)
helpers.deep_sort(t)
for k,v in sortedpairs(t) do
if k == "id" and utils.is_valid_uuid(v) then
if k == "id" and uuid.is_valid_uuid(v) then
t[k] = "UUID"
end
if k == "client_id" or k == "client_secret" or k == "access_token" then
Expand Down
4 changes: 2 additions & 2 deletions 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.uuid"
local uuid = require "kong.tools.uuid"

Schema.new(certificates)
local Snis = assert(Schema.new(snis))
Expand All @@ -27,7 +27,7 @@ end


describe("snis", function()
local certificate = { id = utils.uuid() }
local certificate = { id = uuid.uuid() }

setup_global_env()

Expand Down
4 changes: 2 additions & 2 deletions spec/01-unit/09-balancer/01-generic_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ local dnsA = function(...) return helpers.dnsA(client, ...) end
local dnsExpire = helpers.dnsExpire

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

local ws_id = utils.uuid()
local ws_id = uuid.uuid()

local hc_defaults = {
active = {
Expand Down
4 changes: 2 additions & 2 deletions spec/01-unit/09-balancer/02-least_connections_spec.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

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

local ws_id = utils.uuid()
local ws_id = uuid.uuid()

local client, balancers, targets

Expand Down
Loading

0 comments on commit eccff0c

Please sign in to comment.