Major overhauling and refactoring of Magallanes Command and Tasks modulairty and workflow.

ADVICE: there is no Backwards Compatibility with custom tasks, those
using the _config instance will be broken or those using the
getEnvironmentName().
This commit is contained in:
Andrés Montañez
2012-09-21 00:23:07 -03:00
parent 05b102b273
commit 811c83e13a
29 changed files with 803 additions and 639 deletions
+23 -23
View File
@@ -5,11 +5,11 @@ class Mage_Task_BuiltIn_Deployment_Rsync
{
public function getName()
{
if ($this->_config->release('enabled', false) == true) {
if ($this->getActionOption('overrideRelease', false) == true) {
if ($this->getConfig()->release('enabled', false) == true) {
if ($this->getConfig()->getParameter('overrideRelease', false) == true) {
return 'Rsync (with Releases override) [built-in]';
} else {
return 'Rsync (with Releases) [built-in]';
return 'Rsync (with Releases) [built-in]';
}
} else {
return 'Rsync [built-in]';
@@ -18,13 +18,13 @@ class Mage_Task_BuiltIn_Deployment_Rsync
public function run()
{
$overrideRelease = $this->getActionOption('overrideRelease', false);
$overrideRelease = $this->getConfig()->getParameter('overrideRelease', false);
if ($overrideRelease == true) {
$releaseToOverride = false;
$resultFetch = $this->_runRemoteCommand('ls -ld current | cut -d\"/\" -f2', $releaseToOverride);
if (is_numeric($releaseToOverride)) {
$this->_config->setReleaseId($releaseToOverride);
$this->getConfig()->setReleaseId($releaseToOverride);
}
}
@@ -34,39 +34,39 @@ class Mage_Task_BuiltIn_Deployment_Rsync
'.mage',
'.gitignore'
);
// Look for User Excludes
$userExcludes = $this->_config->deployment('excludes', array());
// If we are working with releases
$deployToDirectory = $this->_config->deployment('to');
if ($this->_config->release('enabled', false) == true) {
$releasesDirectory = $this->_config->release('directory', 'releases');
$deployToDirectory = rtrim($this->_config->deployment('to'), '/')
// Look for User Excludes
$userExcludes = $this->getConfig()->deployment('excludes', array());
// If we are working with releases
$deployToDirectory = $this->getConfig()->deployment('to');
if ($this->getConfig()->release('enabled', false) == true) {
$releasesDirectory = $this->getConfig()->release('directory', 'releases');
$deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/')
. '/' . $releasesDirectory
. '/' . $this->_config->getReleaseId();
$this->_runRemoteCommand('mkdir -p ' . $releasesDirectory . '/' . $this->_config->getReleaseId());
. '/' . $this->getConfig()->getReleaseId();
$this->_runRemoteCommand('mkdir -p ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId());
}
$command = 'rsync -avz '
. '--rsh="ssh -p' . $this->_config->getHostPort() . '" '
. '--rsh="ssh -p' . $this->getConfig()->getHostPort() . '" '
. $this->_excludes(array_merge($excludes, $userExcludes)) . ' '
. $this->_config->deployment('from') . ' '
. $this->_config->deployment('user') . '@' . $this->_config->getHostName() . ':' . $deployToDirectory;
. $this->getConfig()->deployment('from') . ' '
. $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
$result = $this->_runLocalCommand($command);
return $result;
}
private function _excludes(Array $excludes)
{
$excludesRsync = '';
foreach ($excludes as $exclude) {
$excludesRsync .= ' --exclude ' . $exclude . ' ';
}
$excludesRsync = trim($excludesRsync);
return $excludesRsync;
}