Skip to content

Commit

Permalink
refactor(tools/system): move kong.tools.system module out of `kong.…
Browse files Browse the repository at this point in the history
…tools.utils` (#12813)

Putting too many functions into a single module (`kong.tools.utils`) doesn't make sense, we should extract it out of the giant module eventually.

KAG-3137
  • Loading branch information
chronolaw authored Apr 2, 2024
1 parent 20218e3 commit 75fa2ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions kong/reports.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local cjson = require "cjson.safe"
local utils = require "kong.tools.utils"
local system = require "kong.tools.system"
local rand = require "kong.tools.rand"
local constants = require "kong.constants"
local counter = require "resty.counter"
local knode = (kong and kong.node) and kong.node or
Expand Down Expand Up @@ -62,7 +63,7 @@ local REQUEST_ROUTE_CACHE_HITS_KEY_NEG = REQUEST_COUNT_KEY .. ":" .. ROUTE_CACHE
local _buffer = {}
local _ping_infos = {}
local _enabled = false
local _unique_str = utils.random_string()
local _unique_str = rand.random_string()
local _buffer_immutable_idx
local _ssl_session
local _ssl_verify = false
Expand All @@ -75,7 +76,7 @@ do

local meta = require "kong.meta"

local system_infos = utils.get_system_infos()
local system_infos = system.get_system_infos()

system_infos.hostname = system_infos.hostname or knode.get_hostname()

Expand Down
1 change: 0 additions & 1 deletion kong/tools/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ do
"kong.tools.string",
"kong.tools.uuid",
"kong.tools.rand",
"kong.tools.system",
"kong.tools.time",
"kong.tools.ip",
"kong.tools.http",
Expand Down
2 changes: 2 additions & 0 deletions spec/01-unit/05-utils_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local pl_path = require "pl.path"
describe("Utils", function()

describe("get_system_infos()", function()
local utils = require "kong.tools.system"
it("retrieves various host infos", function()
local infos = utils.get_system_infos()
assert.is_number(infos.cores)
Expand All @@ -19,6 +20,7 @@ describe("Utils", function()
end)

describe("get_system_trusted_certs_filepath()", function()
local utils = require "kong.tools.system"
local old_exists = pl_path.exists
after_each(function()
pl_path.exists = old_exists
Expand Down

1 comment on commit 75fa2ae

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:75fa2ae442af961ef456300109919266f7cb7181
Artifacts available https://github.com/Kong/kong/actions/runs/8516902855

Please sign in to comment.