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');
|
assert.func(cb, 'cb');
|
||||||
var cli = opts.cli;
|
var cli = opts.cli;
|
||||||
|
|
||||||
cli.tritonapi.getPolicy({
|
cli.tritonapi.cloudapi.getPolicy({
|
||||||
id: opts.id
|
id: opts.id
|
||||||
}, function onPolicy(err, policy) {
|
}, function onPolicy(err, policy) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -204,7 +204,7 @@ function _editPolicy(opts, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cli.tritonapi.getPolicy({
|
cli.tritonapi.cloudapi.getPolicy({
|
||||||
id: opts.id
|
id: opts.id
|
||||||
}, function onPolicy(err, policy_) {
|
}, function onPolicy(err, policy_) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -701,12 +701,17 @@ function executeRbacUpdatePlan(ctx, cb) {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'update-policy':
|
case 'update-policy':
|
||||||
updateOpts = {id: c.wantThing.name};
|
updateOpts = {id: c.haveThing.id}; // UpdatePolicy requires `id`
|
||||||
extra = [];
|
extra = [];
|
||||||
Object.keys(c.diff).forEach(function (field) {
|
Object.keys(c.diff).forEach(function (field) {
|
||||||
updateOpts[field] = c.wantThing[field];
|
updateOpts[field] = c.wantThing[field];
|
||||||
|
if (field === 'rules') {
|
||||||
// XXX This is poor for large rules update.
|
// 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]));
|
extra.push(format('%s=%s', field, c.wantThing[field]));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ctx.cloudapi.updatePolicy(updateOpts, function (err, poli) {
|
ctx.cloudapi.updatePolicy(updateOpts, function (err, poli) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
Reference in New Issue
Block a user