Skip to content

Commit

Permalink
Merge pull request #28 from amazeeio/hotfix/fix-phpcs-errors
Browse files Browse the repository at this point in the history
Fixes phpcs errors
  • Loading branch information
bomoko authored Nov 13, 2023
2 parents eb9ca01 + 8536a0b commit 4166cbc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/LagoonCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Drush\Drush;
use Drush\SiteAlias\SiteAliasManagerAwareInterface;
use GuzzleHttp\Client;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Process\Process;
use Symfony\Component\Yaml\Yaml;
use \Symfony\Component\HttpKernel\Kernel;

/**
* Drush integration for Lagoon.
Expand Down Expand Up @@ -72,7 +72,7 @@ public function __construct() {
$this->jwt_token = getenv('LAGOON_OVERRIDE_JWT_TOKEN');
$this->projectName = $lagoonyml['project'] ?? '';
$this->ssh_port_timeout = $lagoonyml['ssh_port_timeout'] ?? 30;

// Allow environment variable overrides.
$this->api = getenv('LAGOON_OVERRIDE_API') ?: $this->api;
$this->endpoint = getenv('LAGOON_OVERRIDE_SSH') ?: $this->endpoint;
Expand Down Expand Up @@ -188,33 +188,34 @@ public function getJwtToken() {
[$ssh_host, $ssh_port] = explode(":", $this->endpoint);

$args = [
"-p", $ssh_port,
"-p", $ssh_port,
"-o", "ConnectTimeout=5",
"-o", "LogLevel=FATAL",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
];

if ($this->sshKey) {
$args += ["-i", $this->sshKey];
$args += ["-i", $this->sshKey];
}

$cmd = ["ssh", ...$args, "lagoon@$ssh_host", "token"];

$this->logger()->debug("Retrieving token via SSH -" . implode(" ", $cmd));
if (version_compare(Kernel::VERSION, "4.2", "<")) {
// Symfony >= 4.2 only allows the array form of the command parameter
// Symfony >= 4.2 only allows the array form of the command parameter.
$ssh = new Process(implode(" ", $cmd));
}
else {
$ssh = new Process($cmd);
}

$ssh->setTimeout($this->sshTimeout);

try {
$ssh->mustRun();
} catch (ProcessFailedException $exception) {
$ssh->mustRun();
}
catch (ProcessFailedException $exception) {
$this->logger->debug($ssh->getMessage());
}

Expand Down

0 comments on commit 4166cbc

Please sign in to comment.