From fb0b9619180b0f3ca3252f372aa1cfcfd16a1397 Mon Sep 17 00:00:00 2001 From: Alec Reynolds Date: Fri, 8 Mar 2024 12:08:18 -0800 Subject: [PATCH] lando/lamp#51: Make database healthcheck not rely on pwd/user/db values. --- examples/custom/.lando.yml | 7 +++++++ utils/get-default-healthcheck.js | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/custom/.lando.yml b/examples/custom/.lando.yml index 7cbeb61..3fa2633 100644 --- a/examples/custom/.lando.yml +++ b/examples/custom/.lando.yml @@ -9,6 +9,13 @@ services: database: stuff config: database: config/my.cnf + customnopwd: + type: mariadb:10.3 + portforward: true + creds: + user: pirog + password: + database: stuff customimage: type: mariadb:custom portforward: true 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(' '); };