Skip to content

Commit

Permalink
Update LagoonCommands.php
Browse files Browse the repository at this point in the history
Wrap Lagoon drush command with env condition
  • Loading branch information
skyred authored Nov 10, 2023
1 parent 86a9204 commit bb3db86
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/LagoonCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

/**
Expand Down

0 comments on commit bb3db86

Please sign in to comment.