Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api/deploy): Default to redeploy if to_revision is not set #86

Merged
merged 2 commits into from
Oct 22, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 23 additions & 27 deletions lib/web/handlers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,29 @@ exports.getAPIHandlers = function(dreadnot, authdb) {
// view.
function deploy(req, res) {
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);
}
});
regionName = req.params.region,
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
Expand Down