diff --git a/.github/workflows/pr-backdrop-tests.yml b/.github/workflows/pr-backdrop-tests.yml index 83c06d4..87be1ad 100644 --- a/.github/workflows/pr-backdrop-tests.yml +++ b/.github/workflows/pr-backdrop-tests.yml @@ -14,6 +14,8 @@ jobs: leia-test: - examples/backdrop-custom - examples/backdrop-defaults + - examples/backdrop-downstreamer-1 + - examples/backdrop-downstreamer-2 - examples/backdrop-export - examples/backdrop-import - examples/backdrop-init diff --git a/CHANGELOG.md b/CHANGELOG.md index 93e1801..0cfe5c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v1.2.1 - [March 4, 2024](https://github.com/lando/backdrop/releases/tag/v1.2.1) + +### Fixes + +* Improved `database` selection for purposes of `config` loading, fixes some `database` bootup issues when the `database` type is overriden downstream + ## v1.2.0 - [February 24, 2024](https://github.com/lando/backdrop/releases/tag/v1.2.0) ### New Features diff --git a/examples/backdrop-downstreamer-1/.lando.yml b/examples/backdrop-downstreamer-1/.lando.yml new file mode 100644 index 0000000..f51a385 --- /dev/null +++ b/examples/backdrop-downstreamer-1/.lando.yml @@ -0,0 +1,11 @@ +name: backdrop-downstreamer-1 +recipe: backdrop + +services: + database: + type: mysql:8.0 + +# do not remove this +plugins: + "@lando/backdrop": ../.. + "@lando/mysql": ../../node_modules/@lando/mysql diff --git a/examples/backdrop-downstreamer-1/README.md b/examples/backdrop-downstreamer-1/README.md new file mode 100644 index 0000000..3d8af9d --- /dev/null +++ b/examples/backdrop-downstreamer-1/README.md @@ -0,0 +1,44 @@ +# Backdrop Downstreamer Example + +This example exists primarily to test the following documentation: + +* [Backdrop Recipe](https://docs.lando.dev/backdrop/config.html) + +Start up tests +-------------- + +Run the following commands to get up and running with this example. + +```bash +# Should start up successfully +lando poweroff +lando start +``` + +Verification commands +--------------------- + +Run the following commands to validate things are rolling as they should. + +```bash +# Should be using mysql8 +lando mysql -V | grep 8.0 + +# Should use the default database connection info +lando mysql -ubackdrop -pbackdrop backdrop -e quit + +# Should use the defauly mysql8 config file +lando ssh -s database -c "cat /opt/bitnami/mysql/conf/my_custom.cnf" | grep "LANDOBACKDROPMYSQL8CNF" +lando mysql -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 127 +``` + +Destroy tests +------------- + +Run the following commands to trash this app like nothing ever happened. + +```bash +# Should be destroyed with success +lando destroy -y +lando poweroff +``` diff --git a/examples/backdrop-downstreamer-1/index.php b/examples/backdrop-downstreamer-1/index.php new file mode 100644 index 0000000..f39d159 --- /dev/null +++ b/examples/backdrop-downstreamer-1/index.php @@ -0,0 +1 @@ +DEFAULTS diff --git a/examples/backdrop-downstreamer-1/info.php b/examples/backdrop-downstreamer-1/info.php new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/examples/backdrop-downstreamer-1/info.php @@ -0,0 +1 @@ + diff --git a/examples/backdrop-downstreamer-2/.lando.yml b/examples/backdrop-downstreamer-2/.lando.yml new file mode 100644 index 0000000..a85df65 --- /dev/null +++ b/examples/backdrop-downstreamer-2/.lando.yml @@ -0,0 +1,11 @@ +name: backdrop-downstreamer-2 +recipe: backdrop + +services: + database: + type: backdrop-mysql:8.0 + +# do not remove this +plugins: + "@lando/backdrop": ../.. + "@lando/mysql": ../../node_modules/@lando/mysql diff --git a/examples/backdrop-downstreamer-2/README.md b/examples/backdrop-downstreamer-2/README.md new file mode 100644 index 0000000..3d8af9d --- /dev/null +++ b/examples/backdrop-downstreamer-2/README.md @@ -0,0 +1,44 @@ +# Backdrop Downstreamer Example + +This example exists primarily to test the following documentation: + +* [Backdrop Recipe](https://docs.lando.dev/backdrop/config.html) + +Start up tests +-------------- + +Run the following commands to get up and running with this example. + +```bash +# Should start up successfully +lando poweroff +lando start +``` + +Verification commands +--------------------- + +Run the following commands to validate things are rolling as they should. + +```bash +# Should be using mysql8 +lando mysql -V | grep 8.0 + +# Should use the default database connection info +lando mysql -ubackdrop -pbackdrop backdrop -e quit + +# Should use the defauly mysql8 config file +lando ssh -s database -c "cat /opt/bitnami/mysql/conf/my_custom.cnf" | grep "LANDOBACKDROPMYSQL8CNF" +lando mysql -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 127 +``` + +Destroy tests +------------- + +Run the following commands to trash this app like nothing ever happened. + +```bash +# Should be destroyed with success +lando destroy -y +lando poweroff +``` diff --git a/examples/backdrop-downstreamer-2/index.php b/examples/backdrop-downstreamer-2/index.php new file mode 100644 index 0000000..f39d159 --- /dev/null +++ b/examples/backdrop-downstreamer-2/index.php @@ -0,0 +1 @@ +DEFAULTS diff --git a/examples/backdrop-downstreamer-2/info.php b/examples/backdrop-downstreamer-2/info.php new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/examples/backdrop-downstreamer-2/info.php @@ -0,0 +1 @@ + diff --git a/utils/get-config-defaults.js b/utils/get-config-defaults.js index dcaeea3..9774eb1 100644 --- a/utils/get-config-defaults.js +++ b/utils/get-config-defaults.js @@ -4,15 +4,22 @@ const _ = require('lodash'); const fs = require('fs'); +/* + * Helper to get database type + */ +const getDatabaseType = options => { + return _.get(options, '_app.config.services.database.type', options.database) ?? 'mysql'; +}; + module.exports = options => { // Get the viaconf if (_.startsWith(options.via, 'nginx')) options.defaultFiles.vhosts = 'default.conf.tpl'; // Get the default db conf - const dbConfig = _.get(options, 'database', 'mysql'); + const dbConfig = getDatabaseType(options); const database = _.first(dbConfig.split(':')); const version = _.last(dbConfig.split(':')).substring(0, 2); - if (database === 'mysql' || database === 'mariadb') { + if (database === 'backdrop-mysql' || database === 'mysql' || database === 'mariadb') { if (version === '8.') { options.defaultFiles.database = 'mysql8.cnf'; } else {