diff --git a/CHANGELOG.md b/CHANGELOG.md index ed4d830..40d1bd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Changed builder to enable ssl for proxy urls by default + ## v1.4.2 - [February 7, 2025](https://github.com/lando/phpmyadmin/releases/tag/v1.4.2) * Changed builder to always use latest patch version of `phpmyadmin` diff --git a/builders/phpmyadmin.js b/builders/phpmyadmin.js index a1586ea..5a035f4 100644 --- a/builders/phpmyadmin.js +++ b/builders/phpmyadmin.js @@ -3,6 +3,7 @@ // Modules const _ = require('lodash'); const semver = require('semver'); +const setConfigOptions = require('../utils/setConfigOptions'); // Builder module.exports = { @@ -17,17 +18,22 @@ module.exports = { remoteFiles: { config: '/etc/phpmyadmin/config.user.inc.php', }, + ssl: true, + sslExpose: false, }, - parent: '_lando', - builder: (parent, config) => class LandoPma extends parent { - constructor(id, options = {}) { - options = _.merge({}, config, options); + parent: '_service', + builder: (parent, optionDefaults) => class LandoPma extends parent { + constructor(id, userConfig = {}) { + // Merge the user config onto the default config + const options = _.merge({}, optionDefaults, userConfig); + // Arrayify the hosts if needed if (!_.isArray(options.hosts)) options.hosts = [options.hosts]; // Switch to legacy command if needed if (semver.lt(`${options.version}.0`, '5.0.0')) options.command = '/run.sh phpmyadmin'; - // Build the default stuff here - const pma = { + + // Assemble the service config + const pmaService = { image: `phpmyadmin/phpmyadmin:${options.version}`, environment: { MYSQL_ROOT_PASSWORD: '', @@ -42,10 +48,15 @@ module.exports = { }; // Add some info options.info = {backends: options.hosts}; - options.ssl = true; - options.sslExpose = false; - // Send it downstream - super(id, options, {services: _.set({}, options.name, pma)}); + + // Set configuration options for the upstream Lando service + setConfigOptions({ + ssl: options.ssl, + sslExpose: options.sslExpose, + }, options._app, options.name); + + // Add in the service and push it downstream + super(id, options, {services: _.set({}, options.name, pmaService)}); }; }, }; diff --git a/utils/setConfigOptions.js b/utils/setConfigOptions.js new file mode 100644 index 0000000..f624b8f --- /dev/null +++ b/utils/setConfigOptions.js @@ -0,0 +1,15 @@ +'use strict'; + +const _ = require('lodash'); + +/** + * Sets configuration options for a service + * @param {object} options - The configuration options to set + * @param {object} app - The Lando app object + * @param {string} name - The name of the service + */ +module.exports = (options, app, name) => { + Object.entries(options).forEach(([key, value]) => { + _.set(app, `config.services.${name}.${key}`, value); + }); +};