-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cli] decouple apicast environment and 3scale configuration channel #590
Changes from all commits
acfa344
9558521
1e5e955
786a5c2
ff34ff7
d2aff7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,7 @@ location / { | |
end | ||
} | ||
} | ||
|
||
location /config/ { | ||
echo "{}"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
return { | ||
master_process = 'on', | ||
lua_code_cache = 'on', | ||
configuration_loader = 'boot', | ||
configuration_cache = os.getenv('APICAST_CONFIGURATION_CACHE') or 5*60, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
staging.lua | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
return { | ||
master_process = 'on', | ||
lua_code_cache = 'on', | ||
configuration_loader = 'lazy', | ||
configuration_cache = 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think our staging should always reload configuration. And because of the order of That makes the production.lua |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
requires 'Test::APIcast', '0.07'; | ||
requires 'Test::APIcast', '0.08'; | ||
requires 'Crypt::JWT'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ init_by_lua_block { | |
-- 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 | ||
if type(k) == 'string' and k ~= 'APICAST_CONFIGURATION_LOADER' then | ||
if type(k) == 'string' and not resty_env.value(k) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get this change. Can you explain it, please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sets only missing/empty variables. This leaves the flexibility of overriding the ENV when starting nginx and treating the Because Test::APIcast runs So this change is for two reasons:
|
||
resty_env.set(k,v) | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,18 +75,23 @@ _M.default_config = { | |
|
||
local mt = { __index = _M } | ||
|
||
--- Return loaded environments defined as environment variable. | ||
-- @treturn {string,...} | ||
function _M.loaded() | ||
local value = resty_env.value('APICAST_LOADED_ENVIRONMENTS') | ||
return re.split(value or '', [[\|]], 'jo') | ||
end | ||
|
||
--- Load an environment from files in ENV. | ||
-- @treturn Environment | ||
function _M.load() | ||
local value = resty_env.value('APICAST_LOADED_ENVIRONMENTS') | ||
local env = _M.new() | ||
local environments = _M.loaded() | ||
|
||
if not value then | ||
if not environments then | ||
return env | ||
end | ||
|
||
local environments = re.split(value, '\\|', 'jo') | ||
|
||
for i=1,#environments do | ||
assert(env:add(environments[i])) | ||
end | ||
|
@@ -143,7 +148,7 @@ function _M:add(env) | |
|
||
local config = loadfile(path, 't', { | ||
print = print, inspect = require('inspect'), context = self._context, | ||
tonumber = tonumber, tostring = tostring, | ||
tonumber = tonumber, tostring = tostring, os = { getenv = resty_env.value }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that overriding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. I think it is more useful to expose |
||
pcall = pcall, require = require, assert = assert, error = error, | ||
}) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
use lib 't'; | ||
use Test::APIcast::Blackbox 'no_plan'; | ||
|
||
$ENV{APICAST_CONFIGURATION_LOADER} = 'boot'; | ||
|
||
env_to_nginx( | ||
'APICAST_CONFIGURATION_LOADER', | ||
env_to_apicast( | ||
'APICAST_CONFIGURATION_LOADER' => 'boot' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this allowed before or it's supported since Test::APIcast 0.08 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wasn't really working before Test::APIcast 0.08. |
||
); | ||
|
||
log_level('warn'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
sandbox
and why it's the same as staging?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because some configurations can still have
THREESCALE_DEPLOYMENT_ENV=sandbox
. It was the original value in AMP 2.0 IIRC. We alias it now tostaging
which makes more sense.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍