@@ -24,13 +24,6 @@ class LagoonCommands extends DrushCommands implements SiteAliasManagerAwareInter
2424 */
2525 private $ api ;
2626
27- /**
28- * Cache timeout for API requests.
29- *
30- * @var int
31- */
32- private $ cacheTimeout ;
33-
3427 /**
3528 * Lagoon SSH endpoint.
3629 *
@@ -72,12 +65,11 @@ class LagoonCommands extends DrushCommands implements SiteAliasManagerAwareInter
7265 public function __construct () {
7366 // Get default config.
7467 $ lagoonyml = $ this ->getLagoonYml ();
75- $ this ->api = isset ($ lagoonyml ['api ' ]) ? $ lagoonyml ['api ' ] : 'https://api.lagoon.amazeeio.cloud/graphql ' ;
76- $ this ->cacheTimeout = 600 ;
77- $ this ->endpoint = isset ($ lagoonyml ['ssh ' ]) ? $ lagoonyml ['ssh ' ] : 'ssh.lagoon.amazeeio.cloud:32222 ' ;
68+ $ this ->api = $ lagoonyml ['api ' ] ?? 'https://api.lagoon.amazeeio.cloud/graphql ' ;
69+ $ this ->endpoint = $ lagoonyml ['ssh ' ] ?? 'ssh.lagoon.amazeeio.cloud:32222 ' ;
7870 $ this ->jwt_token = getenv ('LAGOON_OVERRIDE_JWT_TOKEN ' );
79- $ this ->projectName = isset ( $ lagoonyml ['project ' ]) ? $ lagoonyml [ ' project ' ] : '' ;
80- $ this ->ssh_port_timeout = isset ( $ lagoonyml ['ssh_port_timeout ' ]) ? $ lagoonyml [ ' ssh_port_timeout ' ] : 30 ;
71+ $ this ->projectName = $ lagoonyml ['project ' ] ?? '' ;
72+ $ this ->ssh_port_timeout = $ lagoonyml ['ssh_port_timeout ' ] ?? 30 ;
8173
8274 // Allow environment variable overrides.
8375 $ this ->api = getenv ('LAGOON_OVERRIDE_API ' ) ?: $ this ->api ;
@@ -190,16 +182,7 @@ public function getLagoonYml() {
190182 * Retrives a JWT token from the Lagoon SSH endpoint.
191183 */
192184 public function getJwtToken () {
193- // Try to pull the token from the cache.
194- $ cid = "lagoon_jwt_token " ;
195- $ cache = drush_cache_get ($ cid );
196-
197- if (isset ($ cache ->data ) && time () < $ cache ->expire && getenv ('LAGOON_IGNORE_DRUSHCACHE ' ) === FALSE ) {
198- $ this ->logger ()->debug ("Found cached JWT token. " );
199- return $ cache ->data ;
200- }
201-
202- list ($ ssh_host , $ ssh_port ) = explode (": " , $ this ->endpoint );
185+ [$ ssh_host , $ ssh_port ] = explode (": " , $ this ->endpoint );
203186
204187 $ args = "-o ConnectTimeout=5 -o LogLevel=FATAL -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " ;
205188 if ($ this ->sshKey ) {
@@ -214,23 +197,13 @@ public function getJwtToken() {
214197
215198 $ token = trim ($ ssh ->getOutput ());
216199 $ this ->logger ->debug ("JWT Token loaded via ssh: " . $ token );
217- drush_cache_set ($ cid , $ token , 'default ' , $ this ->cacheTimeout );
218200 return $ token ;
219201 }
220202
221203 /**
222204 * Retrieves all information about environments from the Lagoon API.
223205 */
224206 public function getLagoonEnvs () {
225- // Try to pull the token from the cache.
226- $ cid = "lagoon_envs_ " . $ this ->projectName ;
227- $ cache = drush_cache_get ($ cid );
228-
229- if (isset ($ cache ->data ) && time () < $ cache ->expire && getenv ('LAGOON_IGNORE_DRUSHCACHE ' ) === FALSE ) {
230- $ this ->logger ()->debug ("Found cached environments. " );
231- return json_decode ($ cache ->data );
232- }
233-
234207 $ this ->logger ()->debug ("Loading environments for ' $ this ->projectName ' from the API ' $ this ->api ' " );
235208 $ query = sprintf ('{
236209 project:projectByName(name: "%s") {
@@ -264,7 +237,6 @@ public function getLagoonEnvs() {
264237 }
265238
266239 $ this ->logger ->debug ("Response from api: " . var_export (json_decode ($ response ), TRUE ));
267- drush_cache_set ($ cid , $ response , 'default ' , $ this ->cacheTimeout );
268240 return json_decode ($ response );
269241 }
270242
0 commit comments