Skip to content

Commit

Permalink
cli: add push_policy command
Browse files Browse the repository at this point in the history
  • Loading branch information
davidor committed Feb 1, 2019
1 parent 94b6098 commit 9caadaf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions gateway/src/apicast/cli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ _M.commands = load_commands({
'start',
'generate',
'console',
'push_policy'
}, parser)

function mt.__call(self, arg)
Expand Down
31 changes: 31 additions & 0 deletions gateway/src/apicast/cli/command/push_policy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local setmetatable = setmetatable

local policy_pusher = require('apicast.policy_pusher').new()

local _M = { }

local mt = { __index = _M }

function mt.__call(_, opts)
policy_pusher:push(
opts.name, opts.version, opts.admin_portal_domain, opts.access_token
)
end

local function configure(cmd)
cmd:argument('name', 'the name of the policy')
cmd:argument('version', 'the version of the policy')
cmd:argument('admin_portal_domain', 'your admin portal domain. If you are using SaaS it is YOUR_ACCOUNT-admin.3scale.net')
cmd:argument('access_token', 'an access token that you can get from the 3scale admin portal')
return cmd
end

function _M.new(parser)
local cmd = configure(
parser:command('push_policy', 'Push a policy manifest to the 3scale admin portal')
)

return setmetatable({ parser = parser, cmd = cmd }, mt)
end

return setmetatable(_M, mt)

0 comments on commit 9caadaf

Please sign in to comment.