From 82d4f48f6331bace1bdfae688a52068d29e1db89 Mon Sep 17 00:00:00 2001 From: Adam Malone Date: Wed, 20 May 2020 12:05:20 +1000 Subject: [PATCH] Adds in the ability for users to directly configure their environment settings with AcquiaCli. (#87) --- src/Commands/EnvironmentsCommand.php | 29 +++++++++++++++++++++++ tests/AcquiaCliTestCase.php | 3 ++- tests/Commands/EnvironmentCommandTest.php | 4 ++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Commands/EnvironmentsCommand.php b/src/Commands/EnvironmentsCommand.php index b6b4e49..38be004 100644 --- a/src/Commands/EnvironmentsCommand.php +++ b/src/Commands/EnvironmentsCommand.php @@ -231,4 +231,33 @@ public function environmentDelete(Environments $environmentsAdapter, $uuid, $env $this->waitForNotification($response); } } + + /** + * Configures an environment. + * + * Allowed values for configuration update are: + * version: The PHP version. + * max_execution_time: The maximum execution time for PHP scripts. + * memory_limit: The PHP memory limit. + * apcu: The APCu memory limit. + * max_input_vars: The maximum number of input variables. + * max_post_size: The maximum POST size. + * sendmail_path: The path and any options required for sendmail. + * + * @param string $uuid + * @param string $environment + * @param string $key + * @param string $value + * + * @command environment:configure + * @aliases env:config,e:c,environment:config + */ + public function environmentConfigure(Environments $environmentsAdapter, $uuid, $environment, $key, $value) + { + $environment = $this->cloudapiService->getEnvironment($uuid, $environment); + if ($this->confirm(sprintf('Are you sure you want to update the %s environment with [%s => %s]?', $environment->label, $key, $value))) { + $this->say(sprintf('Configuring %s with [%s => %s]', $environment->label, $key, $value)); + $environmentsAdapter->update($environment->uuid, [$key => $value]); + } + } } diff --git a/tests/AcquiaCliTestCase.php b/tests/AcquiaCliTestCase.php index 4d40da0..6c102d3 100644 --- a/tests/AcquiaCliTestCase.php +++ b/tests/AcquiaCliTestCase.php @@ -218,7 +218,8 @@ public static function getFixtureMap() 'post' => 'Ides/createIde.json' ], '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470' => [ - 'delete' => 'Environments/deleteCDEnvironment.json' + 'delete' => 'Environments/deleteCDEnvironment.json', + 'put' => 'Environments/updateEnvironment.json' ], '/environments/32-a47ac10b-58cc-4372-a567-0e02b2c3d470/databases/database1/backups' => [ 'get' => 'DatabaseBackups/getAllDatabaseBackups.json', diff --git a/tests/Commands/EnvironmentCommandTest.php b/tests/Commands/EnvironmentCommandTest.php index 28add59..2a781a1 100644 --- a/tests/Commands/EnvironmentCommandTest.php +++ b/tests/Commands/EnvironmentCommandTest.php @@ -99,6 +99,10 @@ public function environmentProvider() [ ['environment:delete', 'devcloud:devcloud2', 'dev'], '> Deleting Dev environment' . PHP_EOL + ], + [ + ['environment:configure', 'devcloud:devcloud2', 'dev', 'version', '7.4'], + '> Configuring Dev with [version => 7.4]' . PHP_EOL ] ]; }