mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-20 22:45:05 +02:00
Merge dd6490e95f
into 46684ea649
This commit is contained in:
commit
2c45b2a138
42
src/Deploy/Strategy/AbstractStrategy.php
Normal file
42
src/Deploy/Strategy/AbstractStrategy.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of the Magallanes package.
|
||||||
|
*
|
||||||
|
* (c) Stepan Yamilov <yamilovs@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Mage\Deploy\Strategy;
|
||||||
|
|
||||||
|
use Mage\Runtime\Exception\RuntimeException;
|
||||||
|
use Mage\Runtime\Runtime;
|
||||||
|
|
||||||
|
abstract class AbstractStrategy implements StrategyInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Runtime
|
||||||
|
*/
|
||||||
|
protected $runtime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Runtime $runtime
|
||||||
|
*/
|
||||||
|
public function setRuntime(Runtime $runtime)
|
||||||
|
{
|
||||||
|
$this->runtime = $runtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the runtime stage is correct
|
||||||
|
* @param $stage
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function checkStage($stage)
|
||||||
|
{
|
||||||
|
if ($this->runtime->getStage() !== $stage) {
|
||||||
|
throw new RuntimeException(sprintf('Invalid stage, got "%s" but expected "%"', $this->runtime->getStage(), $stage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
namespace Mage\Deploy\Strategy;
|
namespace Mage\Deploy\Strategy;
|
||||||
|
|
||||||
use Mage\Runtime\Exception\RuntimeException;
|
|
||||||
use Mage\Runtime\Runtime;
|
use Mage\Runtime\Runtime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,23 +17,13 @@ use Mage\Runtime\Runtime;
|
||||||
*
|
*
|
||||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||||
*/
|
*/
|
||||||
class ReleasesStrategy implements StrategyInterface
|
class ReleasesStrategy extends AbstractStrategy
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var Runtime
|
|
||||||
*/
|
|
||||||
protected $runtime;
|
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'Releases';
|
return 'Releases';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRuntime(Runtime $runtime)
|
|
||||||
{
|
|
||||||
$this->runtime = $runtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPreDeployTasks()
|
public function getPreDeployTasks()
|
||||||
{
|
{
|
||||||
$this->checkStage(Runtime::PRE_DEPLOY);
|
$this->checkStage(Runtime::PRE_DEPLOY);
|
||||||
|
@ -106,17 +95,4 @@ class ReleasesStrategy implements StrategyInterface
|
||||||
|
|
||||||
return $tasks;
|
return $tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check the runtime stage is correct
|
|
||||||
*
|
|
||||||
* @param $stage
|
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
|
||||||
private function checkStage($stage)
|
|
||||||
{
|
|
||||||
if ($this->runtime->getStage() !== $stage) {
|
|
||||||
throw new RuntimeException(sprintf('Invalid stage, got "%s" but expected "%"', $this->runtime->getStage(), $stage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
namespace Mage\Deploy\Strategy;
|
namespace Mage\Deploy\Strategy;
|
||||||
|
|
||||||
use Mage\Runtime\Exception\RuntimeException;
|
|
||||||
use Mage\Runtime\Runtime;
|
use Mage\Runtime\Runtime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,23 +17,13 @@ use Mage\Runtime\Runtime;
|
||||||
*
|
*
|
||||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||||
*/
|
*/
|
||||||
class RsyncStrategy implements StrategyInterface
|
class RsyncStrategy extends AbstractStrategy
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var Runtime
|
|
||||||
*/
|
|
||||||
protected $runtime;
|
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'Rsync';
|
return 'Rsync';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRuntime(Runtime $runtime)
|
|
||||||
{
|
|
||||||
$this->runtime = $runtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPreDeployTasks()
|
public function getPreDeployTasks()
|
||||||
{
|
{
|
||||||
$this->checkStage(Runtime::PRE_DEPLOY);
|
$this->checkStage(Runtime::PRE_DEPLOY);
|
||||||
|
@ -80,17 +69,4 @@ class RsyncStrategy implements StrategyInterface
|
||||||
|
|
||||||
return $tasks;
|
return $tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check the runtime stage is correct
|
|
||||||
*
|
|
||||||
* @param $stage
|
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
|
||||||
private function checkStage($stage)
|
|
||||||
{
|
|
||||||
if ($this->runtime->getStage() !== $stage) {
|
|
||||||
throw new RuntimeException(sprintf('Invalid stage, got "%s" but expected "%"', $this->runtime->getStage(), $stage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue