-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli) kong prepare cli command to prepare prefix
- Loading branch information
1 parent
1498c45
commit 8bab7f8
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
local prefix_handler = require "kong.cmd.utils.prefix_handler" | ||
local conf_loader = require "kong.conf_loader" | ||
local log = require "kong.cmd.utils.log" | ||
|
||
local function execute(args) | ||
local conf = assert(conf_loader(args.conf, { | ||
prefix = args.prefix | ||
})) | ||
|
||
local ok, err = prefix_handler.prepare_prefix(conf, args.nginx_conf) | ||
if not ok then | ||
log.verbose("could not prepare Kong") | ||
error(err) -- report to main error handler | ||
end | ||
end | ||
|
||
local lapp = [[ | ||
Usage: kong prepare [OPTIONS] | ||
Prepares the Kong prefix in the configured prefix directory. | ||
Options: | ||
-c,--conf (optional string) configuration file | ||
-p,--prefix (optional string) override prefix directory | ||
]] | ||
|
||
return { | ||
lapp = lapp, | ||
execute = execute | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
local helpers = require "spec.helpers" | ||
|
||
describe("kong prepare", function() | ||
setup(function() | ||
helpers.clean_prefix() | ||
end) | ||
teardown(function() | ||
helpers.clean_prefix() | ||
end) | ||
|
||
it("prepares prefix with default conf/prefix", function() | ||
assert(helpers.kong_exec "prepare") | ||
end) | ||
|
||
describe("errors", function() | ||
it("prepare inexistent Kong conf file", function() | ||
local ok, stderr = helpers.kong_exec "prepare --conf foobar.conf" | ||
assert.False(ok) | ||
assert.is_string(stderr) | ||
assert.matches("Error: no file at: foobar.conf", stderr, nil, true) | ||
end) | ||
end) | ||
end) |