[Nostromo] Update Status codes

This commit is contained in:
Andrés Montañez 2017-01-01 16:39:22 -03:00
parent 643fcfcbda
commit 616258e91e
7 changed files with 14 additions and 14 deletions

View file

@ -126,7 +126,7 @@ class DeployCommand extends AbstractCommand
} }
if (!$this->runTasks($output, $preDeployTasks)) { if (!$this->runTasks($output, $preDeployTasks)) {
throw new DeploymentException(sprintf(' Tasks failed on %s stage, halting deployment', $this->getStageName()), 500); throw new DeploymentException(sprintf(' Tasks failed on %s stage, halting deployment', $this->getStageName()), 50);
} }
// Run On Deploy Tasks // Run On Deploy Tasks
@ -158,7 +158,7 @@ class DeployCommand extends AbstractCommand
foreach ($hosts as $host) { foreach ($hosts as $host) {
$this->runtime->setWorkingHost($host); $this->runtime->setWorkingHost($host);
if (!$this->runTasks($output, $onDeployTasks)) { if (!$this->runTasks($output, $onDeployTasks)) {
throw new DeploymentException(sprintf(' Tasks failed on <fg=black;options=bold>%s</> stage, halting deployment', $this->getStageName()), 500); throw new DeploymentException(sprintf(' Tasks failed on <fg=black;options=bold>%s</> stage, halting deployment', $this->getStageName()), 50);
} }
$this->runtime->setWorkingHost(null); $this->runtime->setWorkingHost(null);
} }
@ -182,7 +182,7 @@ class DeployCommand extends AbstractCommand
foreach ($hosts as $host) { foreach ($hosts as $host) {
$this->runtime->setWorkingHost($host); $this->runtime->setWorkingHost($host);
if (!$this->runTasks($output, $onReleaseTasks)) { if (!$this->runTasks($output, $onReleaseTasks)) {
throw new DeploymentException(sprintf(' Tasks failed on <fg=black;options=bold>%s</> stage, halting deployment', $this->getStageName()), 500); throw new DeploymentException(sprintf(' Tasks failed on <fg=black;options=bold>%s</> stage, halting deployment', $this->getStageName()), 50);
} }
$this->runtime->setWorkingHost(null); $this->runtime->setWorkingHost(null);
} }
@ -206,7 +206,7 @@ class DeployCommand extends AbstractCommand
foreach ($hosts as $host) { foreach ($hosts as $host) {
$this->runtime->setWorkingHost($host); $this->runtime->setWorkingHost($host);
if (!$this->runTasks($output, $postReleaseTasks)) { if (!$this->runTasks($output, $postReleaseTasks)) {
throw new DeploymentException(sprintf(' Tasks failed on <fg=black;options=bold>%s</> stage, halting deployment', $this->getStageName()), 500); throw new DeploymentException(sprintf(' Tasks failed on <fg=black;options=bold>%s</> stage, halting deployment', $this->getStageName()), 50);
} }
$this->runtime->setWorkingHost(null); $this->runtime->setWorkingHost(null);
} }
@ -228,7 +228,7 @@ class DeployCommand extends AbstractCommand
} }
if (!$this->runTasks($output, $postDeployTasks)) { if (!$this->runTasks($output, $postDeployTasks)) {
throw new DeploymentException(sprintf(' Tasks failed on <fg=black;options=bold>%s</> stage, halting deployment', $this->getStageName()), 500); throw new DeploymentException(sprintf(' Tasks failed on <fg=black;options=bold>%s</> stage, halting deployment', $this->getStageName()), 50);
} }
} }

View file

@ -61,7 +61,7 @@ class ListCommand extends AbstractCommand
} }
if (!$this->runtime->getEnvironmentConfig('releases', false)) { if (!$this->runtime->getEnvironmentConfig('releases', false)) {
throw new DeploymentException('Releases are not enabled', 700); throw new DeploymentException('Releases are not enabled', 70);
} }
$output->writeln(sprintf(' Environment: <fg=green>%s</>', $this->runtime->getEnvironment())); $output->writeln(sprintf(' Environment: <fg=green>%s</>', $this->runtime->getEnvironment()));
@ -89,7 +89,7 @@ class ListCommand extends AbstractCommand
/** @var Process $process */ /** @var Process $process */
$process = $this->runtime->runRemoteCommand($cmdListReleases, false); $process = $this->runtime->runRemoteCommand($cmdListReleases, false);
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
throw new RuntimeException(sprintf('Unable to retrieve releases from host %s', $host), 800); throw new RuntimeException(sprintf('Unable to retrieve releases from host %s', $host), 80);
} }
$releases = explode(PHP_EOL, trim($process->getOutput())); $releases = explode(PHP_EOL, trim($process->getOutput()));
@ -104,7 +104,7 @@ class ListCommand extends AbstractCommand
/** @var Process $process */ /** @var Process $process */
$process = $this->runtime->runRemoteCommand($cmdCurrentRelease, false); $process = $this->runtime->runRemoteCommand($cmdCurrentRelease, false);
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
throw new RuntimeException(sprintf('Unable to retrieve current release from host %s', $host), 850); throw new RuntimeException(sprintf('Unable to retrieve current release from host %s', $host), 85);
} }
$currentReleaseId = explode('/', trim($process->getOutput())); $currentReleaseId = explode('/', trim($process->getOutput()));

View file

@ -60,7 +60,7 @@ class RollbackCommand extends DeployCommand
} }
if (!$this->runtime->getEnvironmentConfig('releases', false)) { if (!$this->runtime->getEnvironmentConfig('releases', false)) {
throw new DeploymentException('Releases are not enabled', 700); throw new DeploymentException('Releases are not enabled', 70);
} }
// Check if the Release exists in all hosts // Check if the Release exists in all hosts
@ -90,7 +90,7 @@ class RollbackCommand extends DeployCommand
return $exception->getCode(); return $exception->getCode();
} }
} else { } else {
throw new DeploymentException(sprintf('Release %s is not available on all hosts', $releaseToRollback), 720); throw new DeploymentException(sprintf('Release %s is not available on all hosts', $releaseToRollback), 72);
} }
$output->writeln('Finished <fg=blue>Magallanes</>'); $output->writeln('Finished <fg=blue>Magallanes</>');

View file

@ -244,7 +244,7 @@ class Runtime
return $this; return $this;
} }
throw new InvalidEnvironmentException(sprintf('The environment "%s" does not exists.', $environment), 1000); throw new InvalidEnvironmentException(sprintf('The environment "%s" does not exists.', $environment), 100);
} }
/** /**

View file

@ -34,7 +34,7 @@ class CleanupTask extends AbstractTask
public function execute() public function execute()
{ {
if (!$this->runtime->getEnvironmentConfig('releases', false)) { if (!$this->runtime->getEnvironmentConfig('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 400); throw new ErrorException('This task is only available with releases enabled', 40);
} }
$tarGzLocal = $this->runtime->getVar('targz_local'); $tarGzLocal = $this->runtime->getVar('targz_local');

View file

@ -34,7 +34,7 @@ class CopyTask extends AbstractTask
public function execute() public function execute()
{ {
if (!$this->runtime->getEnvironmentConfig('releases', false)) { if (!$this->runtime->getEnvironmentConfig('releases', false)) {
throw new DeploymentException('This task is only available with releases enabled', 400); throw new DeploymentException('This task is only available with releases enabled', 40);
} }
$user = $this->runtime->getEnvironmentConfig('user'); $user = $this->runtime->getEnvironmentConfig('user');

View file

@ -34,7 +34,7 @@ class PrepareTask extends AbstractTask
public function execute() public function execute()
{ {
if (!$this->runtime->getEnvironmentConfig('releases', false)) { if (!$this->runtime->getEnvironmentConfig('releases', false)) {
throw new DeploymentException('This task is only available with releases enabled', 400); throw new DeploymentException('This task is only available with releases enabled', 40);
} }
$tarGzLocal = $this->runtime->getTempFile(); $tarGzLocal = $this->runtime->getTempFile();