rbac: Fix bugs in 'triton rbac policy NAME' and updating a policy in 'triton rbac apply'
This commit is contained in:
parent
3cd4b0d735
commit
5c3a4adee3
@ -39,7 +39,7 @@ function _showPolicy(opts, cb) {
|
||||
assert.func(cb, 'cb');
|
||||
var cli = opts.cli;
|
||||
|
||||
cli.tritonapi.getPolicy({
|
||||
cli.tritonapi.cloudapi.getPolicy({
|
||||
id: opts.id
|
||||
}, function onPolicy(err, policy) {
|
||||
if (err) {
|
||||
@ -204,7 +204,7 @@ function _editPolicy(opts, cb) {
|
||||
}
|
||||
|
||||
|
||||
cli.tritonapi.getPolicy({
|
||||
cli.tritonapi.cloudapi.getPolicy({
|
||||
id: opts.id
|
||||
}, function onPolicy(err, policy_) {
|
||||
if (err) {
|
||||
|
@ -701,12 +701,17 @@ function executeRbacUpdatePlan(ctx, cb) {
|
||||
});
|
||||
break;
|
||||
case 'update-policy':
|
||||
updateOpts = {id: c.wantThing.name};
|
||||
updateOpts = {id: c.haveThing.id}; // UpdatePolicy requires `id`
|
||||
extra = [];
|
||||
Object.keys(c.diff).forEach(function (field) {
|
||||
updateOpts[field] = c.wantThing[field];
|
||||
if (field === 'rules') {
|
||||
// XXX This is poor for large rules update.
|
||||
extra.push(format('%s=%s', field,
|
||||
c.wantThing[field].join(';')));
|
||||
} else {
|
||||
extra.push(format('%s=%s', field, c.wantThing[field]));
|
||||
}
|
||||
});
|
||||
ctx.cloudapi.updatePolicy(updateOpts, function (err, poli) {
|
||||
if (err) {
|
||||
|
Reference in New Issue
Block a user