MXS-1300: Fix minor MaxCtrl bugs

Fixed unresolved promises, wrong resources being requested and enabled
strict mode so unknown arguments are not ignored.
This commit is contained in:
Markus Mäkelä
2017-08-03 09:44:48 +03:00
parent 512c3c018d
commit 3bd13cded6
3 changed files with 7 additions and 5 deletions

View File

@ -193,7 +193,7 @@ exports.builder = function(yargs) {
var promises = [] var promises = []
// Add new monitors // Add new monitors
getDifference(src.monitors.data, dest.monitors.data).forEach(function(i) { getDifference(src.monitors.data, dest.monitors.data).forEach(function(i) {
promises.push(doAsyncRequest(host, 'servers', null, {method: 'POST', body: {data: i}})) promises.push(doAsyncRequest(host, 'monitors', null, {method: 'POST', body: {data: i}}))
}) })
return Promise.all(promises) return Promise.all(promises)
}) })

View File

@ -48,7 +48,9 @@ module.exports = function() {
}) })
return Promise.all(promises) return Promise.all(promises)
.catch(function(err) { .then(function() {
argv.resolve()
}, function(err) {
argv.reject(err) argv.reject(err)
}) })
}, function(err) { }, function(err) {
@ -193,9 +195,9 @@ module.exports = function() {
} }
}, function(err) { }, function(err) {
if (err.response && err.response.body) { if (err.response && err.response.body) {
return error(JSON.stringify(err.response.body, null, 4)) return error('Server responded with an error to resource request `' + resource + '`:' + JSON.stringify(err.response.body, null, 4))
} else if (err.statusCode) { } else if (err.statusCode) {
return error('Server responded with: ' + err.statusCode) return error('Server responded with: ' + err.statusCode + 'to resource request `' + resource + '`')
} else if (err.error) { } else if (err.error) {
return error(JSON.stringify(err.error, null, 4)) return error(JSON.stringify(err.error, null, 4))
} else { } else {
@ -206,7 +208,6 @@ module.exports = function() {
this.doRequest = function(host, resource, cb, obj) { this.doRequest = function(host, resource, cb, obj) {
return doAsyncRequest(host, resource, cb, obj) return doAsyncRequest(host, resource, cb, obj)
.then(this.argv.resolve, this.argv.reject)
} }
this.error = function(err) { this.error = function(err) {

View File

@ -18,6 +18,7 @@ const maxctrl_version = '1.0.0';
program program
.version(maxctrl_version) .version(maxctrl_version)
.strict()
.group(['u', 'p', 'h', 's', 't', 'q', 'tsv'], 'Global Options:') .group(['u', 'p', 'h', 's', 't', 'q', 'tsv'], 'Global Options:')
.option('u', { .option('u', {
alias:'user', alias:'user',