diff --git a/CHANGES.md b/CHANGES.md index fe70fe4..ad63387 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/lib/do_profile/do_create.js b/lib/do_profile/do_create.js index 8157c65..ca78afe 100644 --- a/lib/do_profile/do_create.js +++ b/lib/do_profile/do_create.js @@ -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.' } ]; diff --git a/lib/do_profile/do_docker_setup.js b/lib/do_profile/do_docker_setup.js index 048792e..343c52f 100644 --- a/lib/do_profile/do_docker_setup.js +++ b/lib/do_profile/do_docker_setup.js @@ -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.' } ]; diff --git a/lib/do_profile/profilecommon.js b/lib/do_profile/profilecommon.js index 55a63b9..aeba41d 100644 --- a/lib/do_profile/profilecommon.js +++ b/lib/do_profile/profilecommon.js @@ -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 ' diff --git a/package.json b/package.json index 27328a8..c395bc7 100644 --- a/package.json +++ b/package.json @@ -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": {