mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-09-09 14:58:57 +02:00
Refactor Runtime to allow custom implementation
This commit is contained in:
@@ -20,14 +20,8 @@ use Mage\Runtime\Exception\InvalidEnvironmentException;
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class Runtime
|
||||
class Runtime implements RuntimeInterface
|
||||
{
|
||||
const PRE_DEPLOY = 'pre-deploy';
|
||||
const ON_DEPLOY = 'on-deploy';
|
||||
const POST_DEPLOY = 'post-deploy';
|
||||
const ON_RELEASE = 'on-release';
|
||||
const POST_RELEASE = 'post-release';
|
||||
|
||||
/**
|
||||
* @var array Magallanes configuration
|
||||
*/
|
||||
@@ -72,7 +66,7 @@ class Runtime
|
||||
* Sets the Release ID
|
||||
*
|
||||
* @param string $releaseId Release ID
|
||||
* @return Runtime
|
||||
* @return RuntimeInterface
|
||||
*/
|
||||
public function setReleaseId($releaseId)
|
||||
{
|
||||
@@ -94,7 +88,7 @@ class Runtime
|
||||
* Sets the Runtime in Rollback mode On or Off
|
||||
*
|
||||
* @param bool $inRollback
|
||||
* @return Runtime
|
||||
* @return RuntimeInterface
|
||||
*/
|
||||
public function setRollback($inRollback)
|
||||
{
|
||||
@@ -117,7 +111,7 @@ class Runtime
|
||||
*
|
||||
* @param mixed $key Variable name
|
||||
* @param mixed $value Variable value
|
||||
* @return Runtime
|
||||
* @return RuntimeInterface
|
||||
*/
|
||||
public function setVar($key, $value)
|
||||
{
|
||||
@@ -145,7 +139,7 @@ class Runtime
|
||||
* Sets the Logger instance
|
||||
*
|
||||
* @param LoggerInterface $logger Logger instance
|
||||
* @return Runtime
|
||||
* @return RuntimeInterface
|
||||
*/
|
||||
public function setLogger(LoggerInterface $logger = null)
|
||||
{
|
||||
@@ -157,7 +151,7 @@ class Runtime
|
||||
* Sets the Magallanes Configuration to the Runtime
|
||||
*
|
||||
* @param array $configuration Configuration
|
||||
* @return Runtime
|
||||
* @return RuntimeInterface
|
||||
*/
|
||||
public function setConfiguration($configuration)
|
||||
{
|
||||
@@ -223,7 +217,7 @@ class Runtime
|
||||
* Sets the working Environment
|
||||
*
|
||||
* @param string $environment Environment name
|
||||
* @return Runtime
|
||||
* @return RuntimeInterface
|
||||
* @throws InvalidEnvironmentException
|
||||
*/
|
||||
public function setEnvironment($environment)
|
||||
@@ -250,7 +244,7 @@ class Runtime
|
||||
* Sets the working stage
|
||||
*
|
||||
* @param string $stage Stage code
|
||||
* @return Runtime
|
||||
* @return RuntimeInterface
|
||||
*/
|
||||
public function setStage($stage)
|
||||
{
|
||||
@@ -290,7 +284,7 @@ class Runtime
|
||||
* Sets the working Host
|
||||
*
|
||||
* @param string $host Host name
|
||||
* @return Runtime
|
||||
* @return RuntimeInterface
|
||||
*/
|
||||
public function setWorkingHost($host)
|
||||
{
|
||||
@@ -331,9 +325,9 @@ class Runtime
|
||||
public function runCommand($cmd, $timeout = 120)
|
||||
{
|
||||
switch ($this->getStage()) {
|
||||
case self::ON_DEPLOY:
|
||||
case self::ON_RELEASE:
|
||||
case self::POST_RELEASE:
|
||||
case RuntimeInterface::ON_DEPLOY:
|
||||
case RuntimeInterface::ON_RELEASE:
|
||||
case RuntimeInterface::POST_RELEASE:
|
||||
return $this->runRemoteCommand($cmd, true, $timeout);
|
||||
break;
|
||||
default:
|
||||
@@ -396,6 +390,11 @@ class Runtime
|
||||
return $this->runLocalCommand($cmdLocal, $timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SSH configuration based on the environment
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSSHConfig()
|
||||
{
|
||||
$sshConfig = $this->getEnvironmentConfig('ssh', ['port' => '22', 'flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']);
|
||||
|
||||
Reference in New Issue
Block a user