Merge pull request #5277 from ElvinEfendi/small-refactoring

refactoring: use more specific var name
This commit is contained in:
Kubernetes Prow Robot 2020-03-23 06:02:51 -07:00 committed by GitHub
commit 5cf7018b6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View file

@ -56,13 +56,11 @@ local function get_pem_cert_uid(raw_hostname)
end end
function _M.configured_for_current_request() function _M.configured_for_current_request()
if ngx.ctx.configured_for_current_request ~= nil then if ngx.ctx.cert_configured_for_current_request == nil then
return ngx.ctx.configured_for_current_request ngx.ctx.cert_configured_for_current_request = get_pem_cert_uid(ngx.var.host) ~= nil
end end
ngx.ctx.configured_for_current_request = get_pem_cert_uid(ngx.var.host) ~= nil return ngx.ctx.cert_configured_for_current_request
return ngx.ctx.configured_for_current_request
end end
function _M.call() function _M.call()

View file

@ -135,7 +135,7 @@ describe("Certificate", function()
local _ngx = { var = { host = "hostname" } } local _ngx = { var = { host = "hostname" } }
setmetatable(_ngx, {__index = _G.ngx}) setmetatable(_ngx, {__index = _G.ngx})
_G.ngx = _ngx _G.ngx = _ngx
ngx.ctx.configured_for_current_request = nil ngx.ctx.cert_configured_for_current_request = nil
set_certificate("hostname", EXAMPLE_CERT, UUID) set_certificate("hostname", EXAMPLE_CERT, UUID)
end) end)
@ -150,7 +150,7 @@ describe("Certificate", function()
end) end)
it("returns cached value from ngx.ctx", function() it("returns cached value from ngx.ctx", function()
ngx.ctx.configured_for_current_request = false ngx.ctx.cert_configured_for_current_request = false
assert.is_false(certificate.configured_for_current_request()) assert.is_false(certificate.configured_for_current_request())
end) end)
end) end)