From bb3db869a4d12d2f62df1ee1b7c3f164f96a6f49 Mon Sep 17 00:00:00 2001 From: Jingsheng Wang Date: Sat, 11 Nov 2023 01:50:35 +0800 Subject: [PATCH] Update LagoonCommands.php Wrap Lagoon drush command with env condition --- src/LagoonCommands.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/LagoonCommands.php b/src/LagoonCommands.php index eef69b3..c6eafcf 100644 --- a/src/LagoonCommands.php +++ b/src/LagoonCommands.php @@ -64,20 +64,22 @@ class LagoonCommands extends DrushCommands implements SiteAliasManagerAwareInter * {@inheritdoc} */ public function __construct() { - // Get default config. - $lagoonyml = $this->getLagoonYml(); - $this->api = $lagoonyml['api'] ?? 'https://api.lagoon.amazeeio.cloud/graphql'; - $this->endpoint = $lagoonyml['ssh'] ?? 'ssh.lagoon.amazeeio.cloud:32222'; - $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; - $this->projectName = getenv('LAGOON_PROJECT') ?: $this->projectName; - $this->sshTimeout = getenv('LAGOON_OVERRIDE_SSH_TIMEOUT') ?: $this->sshTimeout; - $this->sshKey = getenv('LAGOON_SSH_KEY'); + if (getenv('LAGOON')) { + // Get default config. + $lagoonyml = $this->getLagoonYml(); + $this->api = $lagoonyml['api'] ?? 'https://api.lagoon.amazeeio.cloud/graphql'; + $this->endpoint = $lagoonyml['ssh'] ?? 'ssh.lagoon.amazeeio.cloud:32222'; + $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; + $this->projectName = getenv('LAGOON_PROJECT') ?: $this->projectName; + $this->sshTimeout = getenv('LAGOON_OVERRIDE_SSH_TIMEOUT') ?: $this->sshTimeout; + $this->sshKey = getenv('LAGOON_SSH_KEY'); + } } /**