Skip to content

Commit

Permalink
style(pdk): get hostname with string.strip
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jun 14, 2024
1 parent 50f5a37 commit e435559
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions kong/pdk/node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@

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


local floor = math.floor
local lower = string.lower
local match = string.match
local gsub = string.gsub
local sort = table.sort
local insert = table.insert
local strip = tools_string.strip
local bytes_to_str = tools_string.bytes_to_str
local ngx = ngx
local shared = ngx.shared
local C = ffi.C
local ffi_new = ffi.new
local ffi_str = ffi.string


local NODE_ID_KEY = "kong:node_id"


Expand Down Expand Up @@ -254,13 +256,13 @@ local function new(self)

if res == 0 then
local hostname = ffi_str(buf, SIZE)
return gsub(hostname, "%z+$", "")
return strip(hostname)
end

local f = io.popen("/bin/hostname")
local hostname = f:read("*a") or ""
f:close()
return gsub(hostname, "\n$", "")
return strip(hostname)
end


Expand Down

0 comments on commit e435559

Please sign in to comment.