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(cli) honor -c flag even if config exists at default location #1681

Merged
merged 1 commit into from
Sep 28, 2016
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
8 changes: 6 additions & 2 deletions kong/conf_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ local function load(path, custom_conf)
if path and not pl_path.exists(path) then
-- file conf has been specified and must exist
return nil, "no file at: "..path
else
-- try to look for a conf, but no big deal if none
elseif not path then
-- try to look for a conf in default locations, but no big
-- deal if none is found: we will use our defaults.
for _, default_path in ipairs(DEFAULT_PATHS) do
if pl_path.exists(default_path) then
path = default_path
Expand Down Expand Up @@ -376,6 +377,9 @@ end

return setmetatable({
load = load,
add_default_path = function(path)
DEFAULT_PATHS[#DEFAULT_PATHS+1] = path
end,
remove_sensitive = function(conf)
local purged_conf = tablex.deepcopy(conf)
for k in pairs(CONF_SENSITIVE) do
Expand Down
11 changes: 11 additions & 0 deletions spec/01-unit/02-conf_loader_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ describe("Configuration loader", function()
assert.True(helpers.path.isabs(conf.ssl_cert))
assert.True(helpers.path.isabs(conf.ssl_cert_key))
end)
it("honors path if provided even if a default file exists", function()
conf_loader.add_default_path("spec/fixtures/to-strip.conf")

finally(function()
package.loaded["kong.conf_loader"] = nil
conf_loader = require "kong.conf_loader"
end)

local conf = assert(conf_loader(helpers.test_conf_path))
assert.equal("postgres", conf.database)
end)
end)

describe("errors", function()
Expand Down