joyent/node-triton#182 'triton profile create' and 'triton profile docker-setup' need a non-interactive option

Reviewed by: Todd Whiteman <todd.whiteman@joyent.com>
Approved by: Todd Whiteman <todd.whiteman@joyent.com>
This commit is contained in:
Trent Mick 2017-02-24 09:29:05 -08:00
parent d91e0326c2
commit b66939751d
5 changed files with 32 additions and 5 deletions

View File

@ -7,6 +7,10 @@ Known issues:
## not yet released
## 5.1.0
- [joyent/node-triton#182] Add `-y, --yes` options to `triton profile create`
and `triton profile docker-setup` to allow non-interactive setup.
## 5.0.0

View File

@ -31,6 +31,7 @@ function _createProfile(opts, cb) {
assert.optionalString(opts.file, 'opts.file');
assert.optionalString(opts.copy, 'opts.copy');
assert.optionalBool(opts.noDocker, 'opts.noDocker');
assert.optionalBool(opts.yes, 'opts.yes');
assert.func(cb, 'cb');
var cli = opts.cli;
var log = cli.log;
@ -366,7 +367,8 @@ function _createProfile(opts, cb) {
cli: cli,
name: data.name,
keyPaths: ctx.keyPaths,
implicit: true
implicit: true,
yes: opts.yes
}, next);
},
@ -411,7 +413,8 @@ function do_create(subcmd, opts, args, cb) {
cli: this.top,
file: opts.file,
copy: opts.copy,
noDocker: opts.no_docker
noDocker: opts.no_docker,
yes: opts.yes
}, cb);
}
@ -442,6 +445,11 @@ do_create.options = [
+ 'non-Windows) to also setup for running Docker. This is '
+ 'experimental and might fail. Use this option to disable '
+ 'the attempt.'
},
{
names: ['yes', 'y'],
type: 'bool',
help: 'Answer yes to any confirmations.'
}
];

View File

@ -21,7 +21,9 @@ function do_docker_setup(subcmd, opts, args, cb) {
var profileName = args[0] || this.top.tritonapi.profile.name;
profilecommon.profileDockerSetup({
cli: this.top,
name: profileName
name: profileName,
implicit: false,
yes: opts.yes
}, cb);
}
@ -30,6 +32,11 @@ do_docker_setup.options = [
names: ['help', 'h'],
type: 'bool',
help: 'Show this help.'
},
{
names: ['yes', 'y'],
type: 'bool',
help: 'Answer yes to any confirmations.'
}
];

View File

@ -141,17 +141,21 @@ function setCurrentProfile(opts, cb) {
* - {Boolean} implicit: Optional. Boolean indicating if the Docker setup
* is implicit (e.g. as a default part of `triton profile create`). If
* implicit, we silently skip if ListServices shows no Docker service.
* - {Boolean} yes: Optional. Boolean indicating if confirmation prompts
* should be skipped, assuming a "yes" answer.
*/
function profileDockerSetup(opts, cb) {
assert.object(opts.cli, 'opts.cli');
assert.string(opts.name, 'opts.name');
assert.optionalBool(opts.implicit, 'opts.implicit');
assert.optionalBool(opts.yes, 'opts.yes');
assert.func(cb, 'cb');
var cli = opts.cli;
var tritonapi = cli.tritonapiFromProfileName({profileName: opts.name});
var implicit = Boolean(opts.implicit);
var yes = Boolean(opts.yes);
var log = cli.log;
var profile = tritonapi.profile;
@ -161,10 +165,14 @@ function profileDockerSetup(opts, cb) {
function dockerKeyWarning(arg, next) {
console.log(wordwrap('WARNING: Docker uses authentication via ' +
'client TLS certificates that do not support encrypted ' +
'(passphrase protected) keys or SSH agents. If you continue,' +
'(passphrase protected) keys or SSH agents. If you continue, ' +
'this profile setup will attempt to write a copy of your ' +
'SSH private key formatted as an unencrypted TLS certificate ' +
'in "~/.triton/docker" for use by the Docker client.\n'));
if (yes) {
next();
return;
}
common.promptYesNo({msg: 'Continue? [y/n] '}, function (answer) {
if (answer !== 'y') {
console.error('Skipping Docker setup (you can run '

View File

@ -1,7 +1,7 @@
{
"name": "triton",
"description": "Joyent Triton CLI and client (https://www.joyent.com/triton)",
"version": "5.0.0",
"version": "5.1.0",
"author": "Joyent (joyent.com)",
"homepage": "https://github.com/joyent/node-triton",
"dependencies": {