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:
@ -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)
|
||||||
})
|
})
|
||||||
|
@ -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) {
|
||||||
|
@ -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',
|
||||||
|
Reference in New Issue
Block a user