From 8cf2908e487f4783249147b679d339a3723ecb20 Mon Sep 17 00:00:00 2001 From: Darko Miletic Date: Wed, 22 Mar 2023 09:35:22 -0300 Subject: [PATCH] When trying to use this tool on anything other than Travis it is harder to make ci script look lean because so many options have to be crammed in the install command line. It would be most useful to have more install options mapped to ENV variables. Fixes #217 --- src/Command/InstallCommand.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index 3158216f..c4dc5805 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -67,6 +67,13 @@ protected function configure(): void $plugin = getenv('CI_BUILD_DIR') !== false ? getenv('CI_BUILD_DIR') : null; } + // Add more options mapped to environment variables. + $db_user = getenv('DB_USER') !== false ? getenv('DB_USER') : null; + $db_pass = getenv('DB_PASS') !== false ? getenv('DB_PASS') : ''; + $db_name = getenv('DB_NAME') !== false ? getenv('DB_NAME') : 'moodle'; + $db_host = getenv('DB_HOST') !== false ? getenv('DB_HOST') : 'localhost'; + $db_port = getenv('DB_PORT') !== false ? getenv('DB_PORT') : ''; + $this->setName('install') ->setDescription('Install everything required for CI testing') ->addOption('moodle', null, InputOption::VALUE_REQUIRED, 'Clone Moodle to this directory', 'moodle') @@ -75,11 +82,11 @@ protected function configure(): void ->addOption('branch', null, InputOption::VALUE_REQUIRED, 'Moodle git branch to clone, EG: MOODLE_29_STABLE', $branch) ->addOption('plugin', null, InputOption::VALUE_REQUIRED, 'Path to Moodle plugin', $plugin) ->addOption('db-type', null, InputOption::VALUE_REQUIRED, 'Database type, mysqli, pgsql or mariadb', $type) - ->addOption('db-user', null, InputOption::VALUE_REQUIRED, 'Database user') - ->addOption('db-pass', null, InputOption::VALUE_REQUIRED, 'Database pass', '') - ->addOption('db-name', null, InputOption::VALUE_REQUIRED, 'Database name', 'moodle') - ->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', 'localhost') - ->addOption('db-port', null, InputOption::VALUE_REQUIRED, 'Database port', '') + ->addOption('db-user', null, InputOption::VALUE_REQUIRED, 'Database user', $db_user) + ->addOption('db-pass', null, InputOption::VALUE_REQUIRED, 'Database pass', $db_pass) + ->addOption('db-name', null, InputOption::VALUE_REQUIRED, 'Database name', $db_name) + ->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', $db_host) + ->addOption('db-port', null, InputOption::VALUE_REQUIRED, 'Database port', $db_port) ->addOption('not-paths', null, InputOption::VALUE_REQUIRED, 'CSV of file paths to exclude', $paths) ->addOption('not-names', null, InputOption::VALUE_REQUIRED, 'CSV of file names to exclude', $names) ->addOption('extra-plugins', null, InputOption::VALUE_REQUIRED, 'Directory of extra plugins to install', $extra)