rbac: Fix bugs in 'triton rbac policy NAME' and updating a policy in 'triton rbac apply'

This commit is contained in:
Trent Mick 2015-12-02 10:05:21 -08:00
parent 3cd4b0d735
commit 5c3a4adee3
2 changed files with 10 additions and 5 deletions

View File

@ -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) {

View File

@ -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];
// XXX This is poor for large rules update.
extra.push(format('%s=%s', 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) {