From fb63a6c245d29e3b7cc2f3ada1ed69e35edee2ee Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 16 Apr 2023 20:22:45 +0100 Subject: [PATCH] feat: opt-in to the new database credentials Allow for changing the default database name, username and password from `drupal` to `app` by enabling the `experimental.useNewDatabaseCredentials` feature flag in a project's `build.yaml` file. Refs: OD-27 --- resources/build.defaults.yaml | 3 +++ src/ConfigurationData.php | 9 +++++++++ templates/env.example.twig | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/resources/build.defaults.yaml b/resources/build.defaults.yaml index 4e477f0..ae494c7 100644 --- a/resources/build.defaults.yaml +++ b/resources/build.defaults.yaml @@ -1,4 +1,7 @@ drupal: docroot: web +experimental: + useNewDatabaseCredentials: false + project_root: /app diff --git a/src/ConfigurationData.php b/src/ConfigurationData.php index 171e8c3..10bd44c 100644 --- a/src/ConfigurationData.php +++ b/src/ConfigurationData.php @@ -32,6 +32,15 @@ final class ConfigurationData )] public array $drupal; + /** + * @var array + */ + #[Assert\Collection( + allowExtraFields: false, + fields: ['useNewDatabaseCredentials' => new Assert\Type('boolean')] + )] + public array $experimental; + #[Assert\Choice(choices: ['node', 'php'])] #[Assert\NotBlank] public string $language; diff --git a/templates/env.example.twig b/templates/env.example.twig index 2b259cf..7c5ee04 100644 --- a/templates/env.example.twig +++ b/templates/env.example.twig @@ -14,7 +14,13 @@ export DOCKER_WEB_VOLUME=.:{{ project_root }} {% endif %} {% if "drupal-project" == type %} +{% if experimental.useNewDatabaseCredentials %} +export MYSQL_DATABASE=app +export MYSQL_PASSWORD=app +export MYSQL_USER=app +{% else %} export MYSQL_DATABASE=drupal export MYSQL_PASSWORD=drupal export MYSQL_USER=drupal {% endif %} +{% endif %}