Skip to content
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

fix(conf) strip/trim specified list values #2206

Merged
merged 1 commit into from
Mar 21, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions kong/conf_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ local function check_and_infer(conf)
-- separated strings to tables (but not when the arr has
-- only one element)
value = setmetatable(pl_stringx.split(value, ","), nil) -- remove List mt

for i = 1, #value do
value[i] = pl_stringx.strip(value[i])
end
end

if value == "" then
Expand Down
4 changes: 4 additions & 0 deletions spec/01-unit/02-conf_loader_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ describe("Configuration loader", function()
assert.is_nil(getmetatable(conf.cassandra_contact_points))
assert.is_nil(getmetatable(conf.cassandra_data_centers))
end)
it("trims array values", function()
local conf = assert(conf_loader("spec/fixtures/to-strip.conf"))
assert.same({"dc1:2", "dc2:3", "dc3:4"}, conf.cassandra_data_centers)
end)
it("infer ngx_boolean", function()
local conf = assert(conf_loader(nil, {
lua_code_cache = true
Expand Down
4 changes: 3 additions & 1 deletion spec/fixtures/to-strip.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ pg_ssl = off # Toggles client-server TLS connections

dns_resolver = 8.8.8.8

cassandra_data_centers = dc1:2, dc2:3 , dc3:4

custom_plugins = foobar,hello-world # Comma-separated list of additional plugins
# this node should load.
# Use this property to load custom plugins
# that are not bundled with Kong.
# Plugins will be loaded from the
# `kong.plugins.{name}.*` namespace.
# `kong.plugins.{name}.*` namespace.