Verify if environment is defined. Verify that rollback has release point.

This commit is contained in:
Andrés Montañez 2012-09-19 18:53:14 -03:00
parent 7d8bf35df4
commit d63ca9cc04
4 changed files with 171 additions and 141 deletions

View file

@ -23,7 +23,13 @@ class Mage_Config
. '/' . md5(microtime()) . '/';
$this->_environment['deployment']['source']['temporal'] = $newTemporal;
}
return true;
} else if (($environment != '') && !file_exists('.mage/config/environment/' . $environment . '.yml')) {
return false;
}
return true;
}
public function loadSCM()

View file

@ -125,7 +125,7 @@ class Mage_Console
// Load Config
$config = new Mage_Config;
$config->loadGeneral();
$config->loadEnvironment($this->getEnvironment());
$environmentOk = $config->loadEnvironment($this->getEnvironment());
$config->loadSCM();
// Logging
@ -142,6 +142,10 @@ class Mage_Console
Mage_Console::output('Starting <blue>Magallanes</blue>', 0, 2);
}
if (!$environmentOk) {
Mage_Console::output('<red>You have selected an invalid environment</red>', 0, 2);
} else {
switch ($this->getAction()) {
case 'deploy':
$task = new Mage_Task_Deploy;
@ -150,12 +154,21 @@ class Mage_Console
case 'releases':
$task = new Mage_Task_Releases;
if (!isset($this->_args[1])) {
Mage_Console::output('<red>You must indicate a task</red>', 0, 2);
break;
}
switch ($this->_args[1]) {
case 'list':
$task->setAction($this->_args[1]);
break;
case 'rollback':
if (!isset($this->_args[2])) {
Mage_Console::output('<red>You must indicate a release point</red>', 0, 2);
break 2;
}
$task->setAction($this->_args[1]);
$task->setRelease($this->_args[2]);
break;
@ -211,6 +224,7 @@ class Mage_Console
Mage_Console::output('<red>Invalid action</red>', 0, 2);
break;
}
}
if ($showGrettings) {
Mage_Console::output('Finished <blue>Magallanes</blue>', 0, 2);

View file

@ -18,6 +18,11 @@ class Mage_Task_Deploy
$this->_startTime = time();
$this->_config = $config;
if ($config->getEnvironment() == '') {
Mage_Console::output('<red>You must specify an environment</red>', 0, 2);
return;
}
// Run Pre-Deployment Tasks
$this->_runNonDeploymentTasks('pre-deploy', $config, 'Pre-Deployment');

View file

@ -31,6 +31,11 @@ class Mage_Task_Releases
{
$this->_config = $config;
if ($config->getEnvironment() == '') {
Mage_Console::output('<red>You must specify an environment</red>', 0, 2);
return;
}
// Run Tasks for Deployment
$hosts = $config->getHosts();