joyent/node-triton#54 'triton rbac {instance,image,network,package,}role-tags ...'

This commit is contained in:
Trent Mick 2015-11-12 16:13:23 -08:00
parent cd611dafde
commit dfbbf309e9
4 changed files with 40 additions and 80 deletions

View File

@ -20,10 +20,8 @@
- `triton rbac key ...` to show, create, edit and delete user keys.
- `triton rbac info` will dump a summary of the full current RBAC
configuration. This command is still in development.
- `triton rbac instance-role-tags ...` to list and manage role tags
on an instance.
- `triton rbac role-tags ...` lower-level command for managing role
tags directly on cloudapi RBAC resource *urls*.
- `triton rbac {instance,image,network,package,}role-tags ...` to list
and manage role tags on each of those resources.
## 2.1.4

View File

@ -210,8 +210,8 @@ function _editRoleTags(opts, cb) {
offerRetry(afterText);
return;
}
console.log('Edited role tags on instance "%s"',
opts.resourceId);
console.log('Edited role tags on %s "%s"',
opts.resourceType, opts.resourceId);
cb();
});
});
@ -415,76 +415,6 @@ function _roleTagsFromArrayOfString(arr) {
}
// ---- `triton rbac role-tags RESOURCE-URL`
//do_role_tags.options = [
// {
// names: ['help', 'h'],
// type: 'bool',
// help: 'Show this help.'
// },
// {
// names: ['json', 'j'],
// type: 'bool',
// help: 'JSON stream output.'
// },
// {
// names: ['yes', 'y'],
// type: 'bool',
// help: 'Answer yes to confirmations, e.g. confirmation of deletion.'
// },
// {
// group: 'Action Options'
// },
// {
// names: ['add', 'a'],
// type: 'arrayOfString',
// helpArg: 'ROLE[,ROLE...]',
// help: 'Add the given role tags. Can be specified multiple times.'
// },
// {
// names: ['set', 's'],
// type: 'arrayOfString',
// helpArg: 'ROLE[,ROLE...]',
// help: 'Set role tags to the given value(s). Can be specified ' +
// 'multiple times.'
// },
// {
// names: ['edit', 'e'],
// type: 'bool',
// help: 'Edit role tags in your $EDITOR.'
// },
// {
// names: ['delete', 'd'],
// type: 'arrayOfString',
// helpArg: 'ROLE[,ROLE...]',
// help: 'Delete the given role tags. Can be specified multiple times.'
// },
// {
// names: ['delete-all', 'D'],
// type: 'bool',
// help: 'Delete all role tags from the given resource.'
// }
//];
//do_role_tags.help = [
// /* BEGIN JSSTYLED */
// 'List and manage role tags for the given instance.',
// '',
// 'Usage:',
// ' {{name}} instance-role-tags INST # list role tags',
// ' {{name}} instance-role-tags -a ROLE[,ROLE...] INST # add',
// ' {{name}} instance-role-tags -s ROLE[,ROLE...] INST # set/replace',
// ' {{name}} instance-role-tags -e INST # edit in $EDITOR',
// ' {{name}} instance-role-tags -d ROLE[,ROLE...] INST # delete',
// ' {{name}} instance-role-tags -D INST # delete all',
// '',
// '{{options}}',
// 'Where "ROLE" is a role tag name (see `triton rbac roles`) and INST is',
// 'an instance "id", "name" or short id.'
// /* END JSSTYLED */
//].join('\n');
function makeRoleTagsFunc(cfg) {
assert.string(cfg.resourceType, 'cfg.resourceType');
assert.string(cfg.funcName, 'cfg.funcName');
@ -666,6 +596,7 @@ var do_role_tags = makeRoleTagsFunc({
argName: 'RESOURCE-URL',
helpArgIs: 'an RBAC resource URL'
});
do_role_tags.hidden = true;
var do_instance_role_tags = makeRoleTagsFunc({
resourceType: 'instance',
@ -675,10 +606,37 @@ var do_instance_role_tags = makeRoleTagsFunc({
helpArgIs: 'an instance "id", "name" or short id'
});
var do_image_role_tags = makeRoleTagsFunc({
resourceType: 'image',
funcName: 'do_image_role_tags',
cmdName: 'image-role-tags',
argName: 'IMG',
helpArgIs: 'an image "id", "name" or short id'
});
var do_network_role_tags = makeRoleTagsFunc({
resourceType: 'network',
funcName: 'do_network_role_tags',
cmdName: 'network-role-tags',
argName: 'NETWORK',
helpArgIs: 'a network "id", "name" or short id'
});
var do_package_role_tags = makeRoleTagsFunc({
resourceType: 'package',
funcName: 'do_package_role_tags',
cmdName: 'package-role-tags',
argName: 'PKG',
helpArgIs: 'a package "id", "name" or short id'
});
module.exports = {
do_role_tags: do_role_tags,
do_instance_role_tags: do_instance_role_tags
do_instance_role_tags: do_instance_role_tags,
do_image_role_tags: do_image_role_tags,
do_network_role_tags: do_network_role_tags,
do_package_role_tags: do_package_role_tags
};

View File

@ -43,7 +43,9 @@ function RbacCLI(top) {
'role',
{ group: 'Role Tags' },
'instance-role-tags',
'role-tags'
'image-role-tags',
'network-role-tags',
'package-role-tags'
]
});
}
@ -68,7 +70,10 @@ RbacCLI.prototype.do_roles = require('./do_roles');
RbacCLI.prototype.do_role = require('./do_role');
var doRoleTags = require('./do_role_tags');
RbacCLI.prototype.do_role_tags = doRoleTags.do_role_tags;
RbacCLI.prototype.do_instance_role_tags = doRoleTags.do_instance_role_tags;
RbacCLI.prototype.do_image_role_tags = doRoleTags.do_image_role_tags;
RbacCLI.prototype.do_network_role_tags = doRoleTags.do_network_role_tags;
RbacCLI.prototype.do_package_role_tags = doRoleTags.do_package_role_tags;
RbacCLI.prototype.do_role_tags = doRoleTags.do_role_tags;
module.exports = RbacCLI;

View File

@ -732,7 +732,6 @@ TritonApi.prototype.setRoleTags = function setRoleTags(opts, cb) {
assert.arrayOfString(opts.roleTags, 'opts.roleTags');
assert.func(cb, 'cb');
vasync.pipeline({arg: {}, funcs: [
function resolveResourceId(ctx, next) {
if (opts.resourceType === 'resource') {