[Nostromo] Refactor Runtime methods.

This commit is contained in:
Andrés Montañez
2017-01-11 22:22:21 -03:00
parent 7493e3cfae
commit b095cd0bb8
24 changed files with 75 additions and 108 deletions
@@ -32,9 +32,9 @@ class CleanupTask extends AbstractTask
public function execute()
{
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$currentReleaseId = $this->runtime->getReleaseId();
$maxReleases = $this->runtime->getEnvParam('releases');
$maxReleases = $this->runtime->getEnvOption('releases');
$cmdListReleases = sprintf('ls -1 %s/releases', $hostPath);
@@ -32,7 +32,7 @@ class PrepareTask extends AbstractTask
public function execute()
{
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$cmdMakeDir = sprintf('mkdir -p %s/releases/%s', $hostPath, $this->runtime->getReleaseId());
+2 -2
View File
@@ -34,11 +34,11 @@ class ReleaseTask extends AbstractTask implements ExecuteOnRollbackInterface
public function execute()
{
if (!$this->runtime->getEnvParam('releases', false)) {
if (!$this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 40);
}
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$releaseId = $this->runtime->getReleaseId();
$cmdLinkRelease = sprintf('cd %s && ln -snf releases/%s current', $hostPath, $releaseId);
+5 -5
View File
@@ -33,14 +33,14 @@ class RsyncTask extends AbstractTask
public function execute()
{
$flags = $this->runtime->getConfigOptions('rsync', '-avz');
$flags = $this->runtime->getConfigOption('rsync', '-avz');
$sshConfig = $this->runtime->getSSHConfig();
$user = $this->runtime->getEnvParam('user', $this->runtime->getCurrentUser());
$user = $this->runtime->getEnvOption('user', $this->runtime->getCurrentUser());
$host = $this->runtime->getWorkingHost();
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$targetDir = rtrim($hostPath, '/');
if ($this->runtime->getEnvParam('releases', false)) {
if ($this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('Can\'t be used with Releases, use "deploy/targz/copy"');
}
@@ -54,7 +54,7 @@ class RsyncTask extends AbstractTask
protected function getExcludes()
{
$excludes = $this->runtime->getEnvParam('exclude', []);
$excludes = $this->runtime->getEnvOption('exclude', []);
$excludes = array_merge(['.git'], $excludes);
foreach ($excludes as &$exclude) {
@@ -33,7 +33,7 @@ class CleanupTask extends AbstractTask
public function execute()
{
if (!$this->runtime->getEnvParam('releases', false)) {
if (!$this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 40);
}
+3 -3
View File
@@ -33,14 +33,14 @@ class CopyTask extends AbstractTask
public function execute()
{
if (!$this->runtime->getEnvParam('releases', false)) {
if (!$this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 40);
}
$user = $this->runtime->getEnvParam('user', $this->runtime->getCurrentUser());
$user = $this->runtime->getEnvOption('user', $this->runtime->getCurrentUser());
$host = $this->runtime->getWorkingHost();
$sshConfig = $sshConfig = $this->runtime->getSSHConfig();
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$currentReleaseId = $this->runtime->getReleaseId();
$targetDir = sprintf('%s/releases/%s', $hostPath, $currentReleaseId);
@@ -33,7 +33,7 @@ class PrepareTask extends AbstractTask
public function execute()
{
if (!$this->runtime->getEnvParam('releases', false)) {
if (!$this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 40);
}
@@ -50,7 +50,7 @@ class PrepareTask extends AbstractTask
protected function getExcludes()
{
$excludes = $this->runtime->getEnvParam('exclude', []);
$excludes = $this->runtime->getEnvOption('exclude', []);
$excludes = array_merge(['.git'], $excludes);
foreach ($excludes as &$exclude) {