Skip to content

Commit

Permalink
lando/lamp#51: Make database healthcheck not rely on pwd/user/db valu…
Browse files Browse the repository at this point in the history
…es. (#42)
  • Loading branch information
reynoldsalec authored Mar 8, 2024
1 parent ae28c19 commit 017dba9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions examples/custom/.lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions utils/get-default-healthcheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
};

0 comments on commit 017dba9

Please sign in to comment.