-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96c8a23
commit d2ebdc9
Showing
5 changed files
with
36 additions
and
6 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 @@ | ||
#!/usr/bin/env lua | ||
|
||
local printable_mt = require "kong.tools.printable" | ||
local constants = require "kong.constants" | ||
local cutils = require "kong.cli.utils" | ||
local IO = require "kong.tools.io" | ||
|
||
local args = require("lapp")(string.format([[ | ||
Usage: kong add-consumer [options] | ||
Options: | ||
-c,--config (default %s) path to configuration file | ||
-n,--username (default none) username | ||
-p,--custom-id (default none) custom id | ||
]], constants.CLI.GLOBAL_KONG_CONF)) | ||
|
||
local config_path = cutils.get_kong_config_path(args.config) | ||
local _, dao_factory = IO.load_configuration_and_dao(config_path) | ||
|
||
local res, err = dao_factory.consumers:insert { | ||
username = args.username ~= "none" and args.username or nil, | ||
custom_id = args["custom-id"] ~= "none" and args["custom-id"] or nil | ||
} | ||
|
||
if err then | ||
cutils.logger:error_exit("Cannot insert consumer: "..err) | ||
elseif res then | ||
setmetatable(res, printable_mt) | ||
cutils.logger:success("Consumer added to Kong: "..res) | ||
end |
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