Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions gateway/http.d/init.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,9 @@ init_by_lua_block {
require("resty.core")

local resty_env = require('resty.env')
-- WARNING, WARNING, WARNING: this is insane hack and should not be touched
-- This file is not templated by Liquid, because it is used by not blackbox integration tests (Search for TEST_NGINX_HTTP_CONFIG).
-- So it cannot be templated by liquid, to lift env variables and persist them in the configuration.
-- This is a workaround so we can store environment at the time of building the config into the config itself.
-- {% raw %} {{ ENV }} {% endraw %} is both valid Liquid template and Lua code.
-- In Lua it is a table with another empty table inside. In Liquid it prints variable ENV.
-- This ENV variable is defined in the main nginx.conf.liquid and injected when including this partial.
-- The content of the ENV variable is a Lua table, so when rendered it actually can run ipairs on it.
for k,v in pairs({{ ENV }}) do
local env_vars = resty_env.list()

for k, v in pairs(env_vars) do
if type(k) == 'string' and not resty_env.value(k) then
resty_env.set(k,v)
end
Expand Down
Loading