This commit is contained in:
Ivan 2018-03-29 22:09:12 +00:00 committed by GitHub
commit fe8a7ad5a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,6 +51,11 @@ class Runtime
*/ */
protected $workingHost = null; protected $workingHost = null;
/**
* @var string|null The port being deployed to
*/
protected $workingPort = null;
/** /**
* @var string|null The Release ID * @var string|null The Release ID
*/ */
@ -348,7 +353,11 @@ class Runtime
*/ */
public function setWorkingHost($host) public function setWorkingHost($host)
{ {
$this->workingHost = $host; //in case port notation is used take only 1st part
$this->workingHost = explode(':', $host)[0];
$port = explode(':', $host);
$this->workingPort = isset($port[1]) ? $port[1] : null;
return $this; return $this;
} }
@ -362,6 +371,16 @@ class Runtime
return $this->workingHost; return $this->workingHost;
} }
/**
* Get the current Host Port or default ssh port
*
* @return integer
*/
public function getWorkingPort()
{
return $this->workingPort;
}
/** /**
* Logs a Message into the Logger * Logs a Message into the Logger
* *
@ -459,8 +478,8 @@ class Runtime
{ {
$sshConfig = $this->getEnvOption('ssh', ['port' => 22, 'flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']); $sshConfig = $this->getEnvOption('ssh', ['port' => 22, 'flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']);
if ($this->getHostPort() !== null) { if ($this->getWorkingPort() !== null) {
$sshConfig['port'] = $this->getHostPort(); $sshConfig['port'] = $this->getWorkingPort();
} }
if (!array_key_exists('port', $sshConfig)) { if (!array_key_exists('port', $sshConfig)) {
@ -474,17 +493,6 @@ class Runtime
return $sshConfig; return $sshConfig;
} }
/**
* Get the current Host Port or default ssh port
*
* @return integer
*/
public function getHostPort()
{
$info = explode(':', $this->getWorkingHost());
return isset($info[1]) ? $info[1] : null;
}
/** /**
* Gets a Temporal File name * Gets a Temporal File name
* *