From c878bbd8fa3c2093f3c19275696298550278b305 Mon Sep 17 00:00:00 2001 From: Alec Reynolds Date: Fri, 8 Mar 2024 12:50:22 -0800 Subject: [PATCH] lando/lamp#51: Make database healthcheck not rely on pwd/user/db values. --- CHANGELOG.md | 5 +++++ examples/custom/.lando.yml | 6 ++++++ utils/get-default-healthcheck.js | 17 ++++++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79825df..f1c7281 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v1.1.0 - [March 8, 2024](https://github.com/lando/mysql/releases/tag/v1.1.0) + +### Fixes +* Allow empty password and other creds fields to pass healthcheck [lando/lamp#51](https://github.com/lando/lamp/issues/51) + ## v1.0.0 - [December 7, 2023](https://github.com/lando/mysql/releases/tag/v1.0.0) * Dialed fully for `lando update` diff --git a/examples/custom/.lando.yml b/examples/custom/.lando.yml index 24e5433..9f330d0 100644 --- a/examples/custom/.lando.yml +++ b/examples/custom/.lando.yml @@ -18,6 +18,12 @@ services: custom_auth: type: mysql:8.0 authentication: mysql_native_password + custom_no_password: + type: mysql:8.0 + creds: + user: pirog + database: stuff + password: tooling: mysql: cmd: mysql diff --git a/utils/get-default-healthcheck.js b/utils/get-default-healthcheck.js index cf67b74..101bd0c 100644 --- a/utils/get-default-healthcheck.js +++ b/utils/get-default-healthcheck.js @@ -2,14 +2,21 @@ // checks to see if a setting is disabled module.exports = options => { - return [ + let healthcheck = [ 'mysql', `--host=${options.name}`, - `--user=${options.creds.user}`, - `--database=${options.creds.database}`, - `--password=${options.creds.password}`, + ]; + + // Only include whatever creds are available. + options.creds.user ? healthcheck.push(`--user=${options.creds.user}`) : false; + options.creds.database ? healthcheck.push(`--database=${options.creds.database}`) : false; + options.creds.password ? healthcheck.push(`--password=${options.creds.password}`) : false; + + healthcheck = healthcheck.concat([ '--silent', '--execute', '"SHOW TABLES;"', - ].join(' '); + ]); + + return healthcheck.join(' '); };