Skip to content

Commit

Permalink
hotfix(conf) load custom plugins property
Browse files Browse the repository at this point in the history
Ensure custom_plugins are passed from the config file to the prefix
config file, and hence down to the runtime OpenResty Kong.

Fix Kong#1906
  • Loading branch information
thibaultcha committed Dec 21, 2016
1 parent 1b4117b commit 9395dcd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion kong/conf_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ local function load(path, custom_conf)
custom_plugins[plugin_name] = true
end
conf.plugins = tablex.merge(constants.PLUGINS_AVAILABLE, custom_plugins, true)
conf.custom_plugins = nil
setmetatable(conf.plugins, nil) -- remove Map mt
end

Expand Down
2 changes: 0 additions & 2 deletions spec/01-unit/02-conf_loader_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ describe("Configuration loader", function()
it("returns a plugins table", function()
local constants = require "kong.constants"
local conf = assert(conf_loader())
assert.is_nil(conf.custom_plugins)
assert.same(constants.PLUGINS_AVAILABLE, conf.plugins)
end)
it("loads custom plugins", function()
local conf = assert(conf_loader(nil, {
custom_plugins = "hello-world,my-plugin"
}))
assert.is_nil(conf.custom_plugins)
assert.True(conf.plugins["hello-world"])
assert.True(conf.plugins["my-plugin"])
end)
Expand Down
12 changes: 12 additions & 0 deletions spec/01-unit/03-prefix_handler_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ describe("NGINX conf compiler", function()
local in_prefix_kong_conf = assert(conf_loader(tmp_config.kong_conf))
assert.same(conf, in_prefix_kong_conf)
end)
it("writes custom plugins in Kong conf", function()
local conf = assert(conf_loader(nil, {
custom_plugins = { "foo", "bar" },
prefix = tmp_config.prefix
}))

assert(prefix_handler.prepare_prefix(conf))

local in_prefix_kong_conf = assert(conf_loader(tmp_config.kong_conf))
assert.True(in_prefix_kong_conf.plugins.foo)
assert.True(in_prefix_kong_conf.plugins.bar)
end)
it("dumps Serf script", function()
assert(prefix_handler.prepare_prefix(tmp_config))

Expand Down

0 comments on commit 9395dcd

Please sign in to comment.