From a2b5a1aba3d2db1c4cf5de3a76d5444d527ae30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 6 May 2020 12:24:21 +0300 Subject: [PATCH] MXS-2980: Forward options to the interactive mode The --quiet option does not make sense in the interactive mode so it isn't forwarded. Added code that reports TLS certificate loading errors. The errors themselves aren't very exact but at least they give a hint as to why it failed. --- maxctrl/lib/common.js | 7 ++++++- maxctrl/lib/core.js | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/maxctrl/lib/common.js b/maxctrl/lib/common.js index 238afdd5b..89627f9fc 100644 --- a/maxctrl/lib/common.js +++ b/maxctrl/lib/common.js @@ -369,7 +369,12 @@ module.exports = function() { args.auth = {user: argv.u, pass: argv.p} args.json = true args.timeout = this.argv.timeout - setTlsCerts(args) + + try { + setTlsCerts(args) + } catch (err) { + return error('Failed to set TLS certificates: ' + JSON.stringify(err, null, 4)) + } return request(args) .then(function(res) { diff --git a/maxctrl/lib/core.js b/maxctrl/lib/core.js index d08d94482..d6ba6c958 100644 --- a/maxctrl/lib/core.js +++ b/maxctrl/lib/core.js @@ -56,7 +56,7 @@ program }) .option('q', { alias: 'quiet', - describe: 'Silence all output', + describe: 'Silence all output. This option is not used in the interactive mode.', default: false, type: 'boolean' }) @@ -123,7 +123,19 @@ program base_opts = ['--user=' + argv.user, '--password=' + argv.password, '--hosts=' + argv.hosts, - '--timeout=' + argv.timeout] + '--timeout=' + argv.timeout, + '--tsv=' + argv.tsv, + '--secure=' + argv.secure, + '--tls-verify-server-cert=' + argv['tls-verify-server-cert']] + + // Only set the string options if they are defined, otherwise we'll end up with the value as + // the string 'undefined' + for (i of ['tls-key', 'tls-cert', 'tls-passphrase', 'tls-ca-cert']) { + if (argv[i]) { + base_opts.push('--' + i + '=' + argv[i]) + } + } + return askQuestion() } else { maxctrl(argv, function() {