-
-
Notifications
You must be signed in to change notification settings - Fork 29
[#1661] Added support for passing prompts in configuration file. #1941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -506,14 +506,21 @@ private function args(string $handler_class, mixed $default_override = NULL, arr | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Find appropriate default value. | ||||||||||||||||||||||||
| $default_from_handler = $handler->default($responses); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| $env_var = static::makeEnvName($id); | ||||||||||||||||||||||||
| $env_val = Env::get($env_var); | ||||||||||||||||||||||||
| // Create the env var name. | ||||||||||||||||||||||||
| $var_name = static::makeEnvName($id); | ||||||||||||||||||||||||
| // Get from config. | ||||||||||||||||||||||||
| $config_val = $this->config->get($var_name); | ||||||||||||||||||||||||
| $default_from_config = is_null($config_val) ? NULL : $config_val; | ||||||||||||||||||||||||
| // Get from env. | ||||||||||||||||||||||||
| $env_val = Env::get($var_name); | ||||||||||||||||||||||||
| $default_from_env = is_null($env_val) ? NULL : Env::toValue($env_val); | ||||||||||||||||||||||||
|
Comment on lines
+512
to
516
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Document typing assumptions and treat empty env as “unset”
Apply: - // Get from config.
+ // Get from config (already typed from parsed JSON).
$config_val = $this->config->get($var_name);
$default_from_config = is_null($config_val) ? NULL : $config_val;
- // Get from env.
- $env_val = Env::get($var_name);
- $default_from_env = is_null($env_val) ? NULL : Env::toValue($env_val);
+ // Get from env (string -> typed). Treat empty string as "unset" to allow fallback.
+ $env_val = Env::get($var_name);
+ $default_from_env = ($env_val === '' || $env_val === NULL) ? NULL : Env::toValue($env_val);Question: Do we want empty env values to be a deliberate way to clear a default, or should they fall back to discovery/handler? Current behavior would silently pick '' (and then omit args['default']), skipping discovery; the change above opts to fall back. Please confirm the desired semantics. 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Get from discovery. | ||||||||||||||||||||||||
| $default_from_discovery = $this->handlers[$id]->discover(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (!is_null($default_from_env)) { | ||||||||||||||||||||||||
| if (!is_null($default_from_config)) { | ||||||||||||||||||||||||
| $default = $default_from_config; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| elseif (!is_null($default_from_env)) { | ||||||||||||||||||||||||
| $default = $default_from_env; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| elseif (!is_null($default_from_discovery)) { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| @@ -99,11 +99,6 @@ | ||
| usage: Run Drush commands in the CLI service container. | ||
| cmd: ahoy cli "vendor/bin/drush -l \${VORTEX_LOCALDEV_URL} $*" | ||
|
|
||
| - flush-valkey: | ||
| - aliases: [flush-redis] | ||
| - usage: Flush Valkey cache. | ||
| - cmd: docker compose exec valkey valkey-cli flushall | ||
| - | ||
| # ---------------------------------------------------------------------------- | ||
| # Application commands. | ||
| # ---------------------------------------------------------------------------- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| @@ -70,10 +70,6 @@ | ||
| # Shield message. | ||
| DRUPAL_SHIELD_PRINT="Restricted access." | ||
|
|
||
| -# Enable Redis/Valkey integration. | ||
| -# See settings.redis.php for details. | ||
| -DRUPAL_REDIS_ENABLED=1 | ||
| - | ||
| # Enable ClamAV integration. | ||
| DRUPAL_CLAMAV_ENABLED=1 | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| @@ -2,12 +2,12 @@ | ||
|
|
||
| # star wars | ||
|
|
||
| -Drupal 11 implementation of star wars for star wars Org | ||
| +Drupal 11 implementation of star wars for My custom org | ||
|
|
||
| -[](https://github.com/star_wars_org/star_wars/actions/workflows/build-test-deploy.yml) | ||
| +[](https://github.com/my_custom_org/star_wars/actions/workflows/build-test-deploy.yml) | ||
|
|
||
|  | ||
| -[](https://codecov.io/gh/star_wars_org/star_wars) | ||
| +[](https://codecov.io/gh/my_custom_org/star_wars) | ||
|
|
||
|  | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| @@ -1,6 +1,6 @@ | ||
| { | ||
| - "name": "star_wars_org/star_wars", | ||
| - "description": "Drupal 11 implementation of star wars for star wars Org", | ||
| + "name": "my_custom_org/star_wars", | ||
| + "description": "Drupal 11 implementation of star wars for My custom org", | ||
| "license": "proprietary", | ||
| "type": "project", | ||
| "require": { | ||
| @@ -17,7 +17,6 @@ | ||
| "drupal/environment_indicator": "__VERSION__", | ||
| "drupal/pathauto": "__VERSION__", | ||
| "drupal/redirect": "__VERSION__", | ||
| - "drupal/redis": "__VERSION__", | ||
| "drupal/robotstxt": "__VERSION__", | ||
| "drupal/search_api": "__VERSION__", | ||
| "drupal/search_api_solr": "__VERSION__", |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| @@ -52,8 +52,6 @@ | ||
| # Drupal Shield credentials. | ||
| DRUPAL_SHIELD_USER: ${DRUPAL_SHIELD_USER:-} | ||
| DRUPAL_SHIELD_PASS: ${DRUPAL_SHIELD_PASS:-} | ||
| - # Valkey integration flag. | ||
| - DRUPAL_REDIS_ENABLED: ${DRUPAL_REDIS_ENABLED:-} | ||
|
|
||
| # The default user under which the containers should run. | ||
| x-user: &default-user | ||
| @@ -146,9 +144,6 @@ | ||
| ports: | ||
| - '3306' # Database port in a container. Find port on host with `ahoy info` or `docker compose port database 3306`. | ||
|
|
||
| - valkey: | ||
| - image: uselagoon/valkey-8:__VERSION__ | ||
| - | ||
| solr: | ||
| build: | ||
| context: . | ||
| @@ -196,8 +191,7 @@ | ||
| - clamav | ||
| - cli | ||
| - database | ||
| - - valkey | ||
| - command: database:3306 clamav:3310 valkey:6379 | ||
| + command: database:3306 clamav:3310 | ||
|
|
||
| networks: ### Use external networks locally. Automatically removed in CI. | ||
| amazeeio-network: ### Automatically removed in CI. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "star_wars", | ||
| - "description": "Drupal 11 implementation of star wars for star wars Org", | ||
| + "description": "Drupal 11 implementation of star wars for My custom org", | ||
| "license": "proprietary", | ||
| "private": true, | ||
| "engines": { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| @@ -42,9 +42,6 @@ | ||
| task "Installing contrib modules." | ||
| drush pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect robotstxt shield stage_file_proxy | ||
|
|
||
| - task "Installing Redis module." | ||
| - drush pm:install redis || true | ||
| - | ||
| task "Installing and configuring ClamAV." | ||
| drush pm:install clamav | ||
| drush config-set clamav.settings mode_daemon_tcpip.hostname clamav |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| @@ -228,105 +228,6 @@ | ||
| } | ||
|
|
||
| /** | ||
| - * Test Valkey settings. | ||
| - */ | ||
| - public function testValkey(): void { | ||
| - $this->setEnvVars([ | ||
| - 'DRUPAL_REDIS_ENABLED' => 1, | ||
| - 'VALKEY_HOST' => 'valkey_host', | ||
| - 'VALKEY_SERVICE_PORT' => 1234, | ||
| - 'VORTEX_REDIS_EXTENSION_LOADED' => 1, | ||
| - ]); | ||
| - | ||
| - $this->requireSettingsFile(); | ||
| - | ||
| - $settings['redis.connection']['interface'] = 'PhpRedis'; | ||
| - $settings['redis.connection']['host'] = 'valkey_host'; | ||
| - $settings['redis.connection']['port'] = 1234; | ||
| - $settings['cache']['default'] = 'cache.backend.redis'; | ||
| - | ||
| - $this->assertArrayHasKey('bootstrap_container_definition', $this->settings); | ||
| - unset($this->settings['bootstrap_container_definition']); | ||
| - | ||
| - $this->assertSettingsContains($settings); | ||
| - } | ||
| - | ||
| - /** | ||
| - * Test Valkey partial settings. | ||
| - */ | ||
| - public function testValkeyPartial(): void { | ||
| - $this->setEnvVars([ | ||
| - 'DRUPAL_REDIS_ENABLED' => 1, | ||
| - 'VALKEY_HOST' => 'valkey_host', | ||
| - 'VALKEY_SERVICE_PORT' => 1234, | ||
| - 'VORTEX_REDIS_EXTENSION_LOADED' => 0, | ||
| - ]); | ||
| - | ||
| - $this->requireSettingsFile(); | ||
| - | ||
| - $settings['redis.connection']['interface'] = 'PhpRedis'; | ||
| - $settings['redis.connection']['host'] = 'valkey_host'; | ||
| - $settings['redis.connection']['port'] = 1234; | ||
| - $no_settings['cache']['default'] = 'cache.backend.redis'; | ||
| - | ||
| - $this->assertArrayNotHasKey('bootstrap_container_definition', $this->settings); | ||
| - | ||
| - $this->assertSettingsContains($settings); | ||
| - $this->assertSettingsNotContains($no_settings); | ||
| - } | ||
| - | ||
| - /** | ||
| - * Test Redis settings with REDIS_* environment variables. | ||
| - */ | ||
| - public function testRedisVariables(): void { | ||
| - $this->setEnvVars([ | ||
| - 'DRUPAL_REDIS_ENABLED' => 1, | ||
| - 'REDIS_HOST' => 'redis_host', | ||
| - 'REDIS_SERVICE_PORT' => 6380, | ||
| - 'VORTEX_REDIS_EXTENSION_LOADED' => 1, | ||
| - ]); | ||
| - | ||
| - $this->requireSettingsFile(); | ||
| - | ||
| - $settings['redis.connection']['interface'] = 'PhpRedis'; | ||
| - $settings['redis.connection']['host'] = 'redis_host'; | ||
| - $settings['redis.connection']['port'] = 6380; | ||
| - $settings['cache']['default'] = 'cache.backend.redis'; | ||
| - | ||
| - $this->assertArrayHasKey('bootstrap_container_definition', $this->settings); | ||
| - unset($this->settings['bootstrap_container_definition']); | ||
| - | ||
| - $this->assertSettingsContains($settings); | ||
| - } | ||
| - | ||
| - /** | ||
| - * Test Redis fallback when both VALKEY_* and REDIS_* variables are set. | ||
| - */ | ||
| - public function testRedisValkeyPrecedence(): void { | ||
| - $this->setEnvVars([ | ||
| - 'DRUPAL_REDIS_ENABLED' => 1, | ||
| - 'VALKEY_HOST' => 'valkey_host', | ||
| - 'VALKEY_SERVICE_PORT' => 1234, | ||
| - 'REDIS_HOST' => 'redis_host', | ||
| - 'REDIS_SERVICE_PORT' => 6380, | ||
| - 'VORTEX_REDIS_EXTENSION_LOADED' => 1, | ||
| - ]); | ||
| - | ||
| - $this->requireSettingsFile(); | ||
| - | ||
| - // VALKEY_* variables should take precedence over REDIS_* variables. | ||
| - $settings['redis.connection']['interface'] = 'PhpRedis'; | ||
| - $settings['redis.connection']['host'] = 'valkey_host'; | ||
| - $settings['redis.connection']['port'] = 1234; | ||
| - $settings['cache']['default'] = 'cache.backend.redis'; | ||
| - | ||
| - $this->assertArrayHasKey('bootstrap_container_definition', $this->settings); | ||
| - unset($this->settings['bootstrap_container_definition']); | ||
| - | ||
| - $this->assertSettingsContains($settings); | ||
| - } | ||
| - | ||
| - /** | ||
| * Test Shield config. | ||
| */ | ||
| #[DataProvider('dataProviderShield')] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| @@ -74,15 +74,6 @@ | ||
| # See settings.redis.php for details. | ||
| DRUPAL_REDIS_ENABLED=1 | ||
|
|
||
| -# Enable ClamAV integration. | ||
| -DRUPAL_CLAMAV_ENABLED=1 | ||
| - | ||
| -# ClamAV mode. | ||
| -# | ||
| -# Run ClamAV in either daemon mode by setting it to 0 (or 'daemon') or in | ||
| -# executable mode by setting it to 1. | ||
| -DRUPAL_CLAMAV_MODE=daemon | ||
| - | ||
| ################################################################################ | ||
| # PROVISION # | ||
| ################################################################################ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| @@ -2,12 +2,12 @@ | ||
|
|
||
| # star wars | ||
|
|
||
| -Drupal 11 implementation of star wars for star wars Org | ||
| +Drupal 11 implementation of star wars for My other custom org | ||
|
|
||
| -[](https://github.com/star_wars_org/star_wars/actions/workflows/build-test-deploy.yml) | ||
| +[](https://github.com/my_other_custom_org/star_wars/actions/workflows/build-test-deploy.yml) | ||
|
|
||
|  | ||
| -[](https://codecov.io/gh/star_wars_org/star_wars) | ||
| +[](https://codecov.io/gh/my_other_custom_org/star_wars) | ||
|
|
||
|  | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| @@ -1,6 +1,6 @@ | ||
| { | ||
| - "name": "star_wars_org/star_wars", | ||
| - "description": "Drupal 11 implementation of star wars for star wars Org", | ||
| + "name": "my_other_custom_org/star_wars", | ||
| + "description": "Drupal 11 implementation of star wars for My other custom org", | ||
| "license": "proprietary", | ||
| "type": "project", | ||
| "require": { | ||
| @@ -8,7 +8,6 @@ | ||
| "composer/installers": "__VERSION__", | ||
| "cweagans/composer-patches": "__VERSION__", | ||
| "drupal/admin_toolbar": "__VERSION__", | ||
| - "drupal/clamav": "__VERSION__", | ||
| "drupal/coffee": "__VERSION__", | ||
| "drupal/config_split": "__VERSION__", | ||
| "drupal/config_update": "__VERSION__", |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| @@ -166,17 +166,6 @@ | ||
| ports: | ||
| - '8983' # Solr port in a container. Find port on host with `ahoy info` or `docker compose port solr 8983`. | ||
|
|
||
| - clamav: | ||
| - build: | ||
| - context: . | ||
| - dockerfile: .docker/clamav.dockerfile | ||
| - environment: | ||
| - <<: *default-environment | ||
| - ports: | ||
| - - '3310' # Find port on host with `docker compose port clamav 3310`. | ||
| - networks: | ||
| - - default | ||
| - | ||
| # Chrome container, used for browser testing. | ||
| chrome: | ||
| image: selenium/standalone-chromium:__VERSION__ | ||
| @@ -193,11 +182,10 @@ | ||
| wait_dependencies: | ||
| image: drevops/docker-wait-for-dependencies:__VERSION__ | ||
| depends_on: | ||
| - - clamav | ||
| - cli | ||
| - database | ||
| - valkey | ||
| - command: database:3306 clamav:3310 valkey:6379 | ||
| + command: database:3306 valkey:6379 | ||
|
|
||
| networks: ### Use external networks locally. Automatically removed in CI. | ||
| amazeeio-network: ### Automatically removed in CI. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "star_wars", | ||
| - "description": "Drupal 11 implementation of star wars for star wars Org", | ||
| + "description": "Drupal 11 implementation of star wars for My other custom org", | ||
| "license": "proprietary", | ||
| "private": true, | ||
| "engines": { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| @@ -45,10 +45,6 @@ | ||
| task "Installing Redis module." | ||
| drush pm:install redis || true | ||
|
|
||
| - task "Installing and configuring ClamAV." | ||
| - drush pm:install clamav | ||
| - drush config-set clamav.settings mode_daemon_tcpip.hostname clamav | ||
| - | ||
| task "Installing Solr search modules." | ||
| drush pm:install search_api search_api_solr | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Harden config file loading and produce actionable errors.
file_get_contents()fails, it returns false and silently becomes an empty string; this leads to a confusing JSON parse error later.Apply:
And wrap parsing to add context:
🤖 Prompt for AI Agents