Skip to content

Commit

Permalink
fix bug clobbering default recipe proxy url when user specifies once
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Sep 6, 2024
1 parent 022f95c commit 3c7f166
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

## Bug Fixes

* Fixed bug causing default `proxy` settings to be clobbered by user specified ones

## Internal

* Updated DevOps to use new `lando exec`
* Updated `ubuntu` test runners to `24.04`

## v1.5.0 - [May 27, 2024](https://github.com/lando/laravel/releases/tag/v1.5.0)

* Updated mariadb plugin [#51](https://github.com/lando/mariadb/issues/51)
Expand Down
26 changes: 19 additions & 7 deletions builders/laravel.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ const getDbTooling = database => {
}
};

/*
* Helper to get proxy config
*/
const getProxy = (options, proxyService = 'appserver') => {
// get any intial proxy stuff for proxyService
const urls = _.get(options, `_app.config.proxy.${proxyService}`, []);
// add
urls.push(`${options.app}.${options._app._config.domain}`);
// return
return {[proxyService]: _.uniq(_.compact(urls))};
};

/*
* Helper to get service config
*/
Expand Down Expand Up @@ -267,8 +279,15 @@ module.exports = {
options.services.cache = getCache(options.cache);
}

// Switch the proxy if needed
if (!_.has(options, 'proxyService')) {
if (_.startsWith(options.via, 'nginx')) options.proxyService = 'appserver_nginx';
else if (_.startsWith(options.via, 'apache')) options.proxyService = 'appserver';
}

// Rebase on top of any default config we might already have
options.defaultFiles = _.merge({}, getConfigDefaults(_.cloneDeep(options)), options.defaultFiles);
options.proxy = _.merge({}, getProxy(options, options.proxyService), options.proxy);
options.services = _.merge({}, getServices(options), options.services);
options.tooling = _.merge({}, getTooling(options), options.tooling);

Expand All @@ -279,13 +298,6 @@ module.exports = {
cmd: `php /app/${options.webroot}/../artisan`,
};

// Switch the proxy if needed
if (!_.has(options, 'proxyService')) {
if (_.startsWith(options.via, 'nginx')) options.proxyService = 'appserver_nginx';
else if (_.startsWith(options.via, 'apache')) options.proxyService = 'appserver';
}
options.proxy = _.set(options.proxy, options.proxyService, [`${options.app}.${options._app._config.domain}`]);

// Send downstream
super(id, _.merge({}, config, options));
};
Expand Down
3 changes: 3 additions & 0 deletions examples/laravel-custom/.lando.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: laravel-custom
proxy:
appserver_nginx:
- another.laravel-custom.lndo.site
recipe: laravel
config:
php: '8.3'
Expand Down
4 changes: 4 additions & 0 deletions examples/laravel-custom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ lando exec cache -- memcached --version | grep 1.5.12
# Should have xdebug enabled
lando php -m | grep Xdebug

# Should have proxy urls present in lando info
lando info | grep "http://laravel-custom.lndo.site"
lando info | grep "http://another.laravel-custom.lndo.site"

# Should be using custom config files
lando exec appserver -- curl -L appserver_nginx/info.php | grep max_execution_time | grep 92
lando exec appserver_nginx -- cat /opt/bitnami/nginx/conf/vhosts/lando.conf | grep server_name | grep pirog
Expand Down

0 comments on commit 3c7f166

Please sign in to comment.