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:
parent
512c3c018d
commit
3bd13cded6
@ -193,7 +193,7 @@ exports.builder = function(yargs) {
|
||||
var promises = []
|
||||
// Add new monitors
|
||||
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)
|
||||
})
|
||||
|
@ -48,7 +48,9 @@ module.exports = function() {
|
||||
})
|
||||
|
||||
return Promise.all(promises)
|
||||
.catch(function(err) {
|
||||
.then(function() {
|
||||
argv.resolve()
|
||||
}, function(err) {
|
||||
argv.reject(err)
|
||||
})
|
||||
}, function(err) {
|
||||
@ -193,9 +195,9 @@ module.exports = function() {
|
||||
}
|
||||
}, function(err) {
|
||||
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) {
|
||||
return error('Server responded with: ' + err.statusCode)
|
||||
return error('Server responded with: ' + err.statusCode + 'to resource request `' + resource + '`')
|
||||
} else if (err.error) {
|
||||
return error(JSON.stringify(err.error, null, 4))
|
||||
} else {
|
||||
@ -206,7 +208,6 @@ module.exports = function() {
|
||||
|
||||
this.doRequest = function(host, resource, cb, obj) {
|
||||
return doAsyncRequest(host, resource, cb, obj)
|
||||
.then(this.argv.resolve, this.argv.reject)
|
||||
}
|
||||
|
||||
this.error = function(err) {
|
||||
|
@ -18,6 +18,7 @@ const maxctrl_version = '1.0.0';
|
||||
|
||||
program
|
||||
.version(maxctrl_version)
|
||||
.strict()
|
||||
.group(['u', 'p', 'h', 's', 't', 'q', 'tsv'], 'Global Options:')
|
||||
.option('u', {
|
||||
alias:'user',
|
||||
|
Loading…
x
Reference in New Issue
Block a user