From 45b531db2e0fe434f5e12cf237f33f5b1808203e Mon Sep 17 00:00:00 2001 From: kaustav haldar Date: Tue, 20 Oct 2015 13:00:06 -0700 Subject: [PATCH 1/2] feat(api/deploy): Allow automatic deploys without specifying to revision by making it default to current revision of that stack thats been deployed --- lib/web/handlers/api.js | 50 +++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/lib/web/handlers/api.js b/lib/web/handlers/api.js index e8190eb..161d12d 100644 --- a/lib/web/handlers/api.js +++ b/lib/web/handlers/api.js @@ -77,34 +77,30 @@ exports.getAPIHandlers = function(dreadnot, authdb) { // stack locked errors, redirect to the region view, otherwise a full error // view. function deploy(req, res) { - var stackName = req.params.stack, + var stackName = req.params.stack, regionName = req.params.region, - to = req.body.to_revision, user; - - async.waterfall([ - dreadnot.deploy.bind(dreadnot, stackName, regionName, to, req.remoteUser.name), - - function(number, callback) { - dreadnot.getDeploymentSummary(stackName, regionName, number, callback); - } - ], res.respond); - } - - function getWarning(req, res) { - res.respond(null, {message: dreadnot.warning}); - } - - // Store the warning message - function saveWarning(req, res) { - var text = req.body.action === 'save' ? req.body.warning_text : ''; - - dreadnot.setWarning(req.remoteUser, text, function(err) { - if (err) { - res.respond(err); - } else { - getWarning(req, res); - } - }); + to; + + function deploy() { + async.waterfall([ + dreadnot.deploy.bind(dreadnot, stackName, regionName, to, req.remoteUser.name), + + function(number, callback) { + dreadnot.getDeploymentSummary(stackName, regionName, number, callback); + } + ], res.respond); + } + + //Make the to_revision field optional + if (typeof req.body !== 'undefined' || typeof req.body.to_revision !== 'undefined') { + to = req.body.to_revision; + deploy(); + } else { + dreadnot.getStackSummary(req.params.stack, function(err, data) { + to = data["latest_revision"]; + deploy(); + }); + } } // Return bound handlers From a34e78eaba6fb9dab9e9e25d6b5849057acd4a1c Mon Sep 17 00:00:00 2001 From: Michael Burns Date: Thu, 22 Oct 2015 16:29:33 -0700 Subject: [PATCH 2/2] lint --- lib/web/handlers/api.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/web/handlers/api.js b/lib/web/handlers/api.js index 161d12d..0cd8c5b 100644 --- a/lib/web/handlers/api.js +++ b/lib/web/handlers/api.js @@ -77,9 +77,9 @@ exports.getAPIHandlers = function(dreadnot, authdb) { // stack locked errors, redirect to the region view, otherwise a full error // view. function deploy(req, res) { - var stackName = req.params.stack, - regionName = req.params.region, - to; + var stackName = req.params.stack, + regionName = req.params.region, + to; function deploy() { async.waterfall([