Skip to content

Commit

Permalink
refactor(tools): remove reference of gzip module from utils.lua (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw authored Nov 14, 2023
1 parent c3e09ef commit 36f2abe
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion kong/clustering/compat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local table_insert = table.insert
local table_sort = table.sort
local gsub = string.gsub
local split = utils.split
local deflate_gzip = utils.deflate_gzip
local deflate_gzip = require("kong.tools.gzip").deflate_gzip
local cjson_encode = cjson.encode

local ngx = ngx
Expand Down
5 changes: 2 additions & 3 deletions kong/clustering/control_plane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ local _MT = { __index = _M, }
local semaphore = require("ngx.semaphore")
local cjson = require("cjson.safe")
local declarative = require("kong.db.declarative")
local utils = require("kong.tools.utils")
local clustering_utils = require("kong.clustering.utils")
local compat = require("kong.clustering.compat")
local constants = require("kong.constants")
Expand Down Expand Up @@ -41,8 +40,8 @@ local sleep = ngx.sleep

local plugins_list_to_map = compat.plugins_list_to_map
local update_compatible_payload = compat.update_compatible_payload
local deflate_gzip = utils.deflate_gzip
local yield = utils.yield
local deflate_gzip = require("kong.tools.gzip").deflate_gzip
local yield = require("kong.tools.yield").yield
local connect_dp = clustering_utils.connect_dp


Expand Down
5 changes: 2 additions & 3 deletions kong/clustering/data_plane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ local config_helper = require("kong.clustering.config_helper")
local clustering_utils = require("kong.clustering.utils")
local declarative = require("kong.db.declarative")
local constants = require("kong.constants")
local utils = require("kong.tools.utils")
local pl_stringx = require("pl.stringx")


Expand All @@ -25,8 +24,8 @@ local cjson_decode = cjson.decode
local cjson_encode = cjson.encode
local exiting = ngx.worker.exiting
local ngx_time = ngx.time
local inflate_gzip = utils.inflate_gzip
local yield = utils.yield
local inflate_gzip = require("kong.tools.gzip").inflate_gzip
local yield = require("kong.tools.yield").yield


local ngx_ERR = ngx.ERR
Expand Down
1 change: 0 additions & 1 deletion kong/tools/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,6 @@ _M.topological_sort = topological_sort

do
local modules = {
"kong.tools.gzip",
"kong.tools.table",
"kong.tools.sha256",
"kong.tools.yield",
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 @@ -754,6 +754,8 @@ describe("Utils", function()
end)

describe("gzip_[de_in]flate()", function()
local utils = require "kong.tools.gzip"

it("empty string", function()
local gz = assert(utils.deflate_gzip(""))
assert.equal(utils.inflate_gzip(gz), "")
Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/19-hybrid/03-compat_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local compat = require("kong.clustering.compat")
local helpers = require ("spec.helpers")
local declarative = require("kong.db.declarative")
local inflate_gzip = require("kong.tools.utils").inflate_gzip
local inflate_gzip = require("kong.tools.gzip").inflate_gzip
local cjson_decode = require("cjson.safe").decode
local ssl_fixtures = require ("spec.fixtures.ssl")

Expand Down
4 changes: 3 additions & 1 deletion spec/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3788,6 +3788,8 @@ local function clustering_client(opts)
assert(opts.cert)
assert(opts.cert_key)

local inflate_gzip = require("kong.tools.gzip").inflate_gzip

local c = assert(ws_client:new())
local uri = "wss://" .. opts.host .. ":" .. opts.port ..
"/v1/outlet?node_id=" .. (opts.node_id or utils.uuid()) ..
Expand Down Expand Up @@ -3820,7 +3822,7 @@ local function clustering_client(opts)
c:close()

if typ == "binary" then
local odata = assert(utils.inflate_gzip(data))
local odata = assert(inflate_gzip(data))
local msg = assert(cjson.decode(odata))
return msg

Expand Down

1 comment on commit 36f2abe

@khcp-gha-bot
Copy link

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:36f2abe5dae9d4b43c0320eb84b6fb859a945ef0
Artifacts available https://github.com/Kong/kong/actions/runs/6860251773

Please sign in to comment.