Skip to content

Commit

Permalink
fix bug causing proxy route merge failure
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Sep 5, 2024
1 parent 140b522 commit 7b5737e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
27 changes: 19 additions & 8 deletions builders/_drupaly.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,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 All @@ -205,7 +217,6 @@ const getServiceConfig = (options, types = ['php', 'server', 'vhosts']) => {
*/
const getTooling = options => _.merge({}, toolingDefaults, getDbTooling(options.database));


/*
* Build Drupal 7
*/
Expand Down Expand Up @@ -260,17 +271,17 @@ module.exports = {
},
}}});

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

// Switch the proxy if needed
// Switch the proxy service 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}`]);

// 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);

// Send downstream
super(id, _.merge({}, config, options));
Expand Down
Empty file removed examples/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion examples/.lando.upstream.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
plugins:
"@lando/drupal": ./../../../
"@lando/drupal": ../../..
3 changes: 3 additions & 0 deletions examples/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: placeholder
plugins:
"@lando/drupal": ..
5 changes: 5 additions & 0 deletions examples/drupal7/.lando.upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
proxy:
appserver:
- another.lando-drupal7.lndo.site
plugins:
"@lando/drupal": ../../..
15 changes: 8 additions & 7 deletions examples/drupal7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ lando init --source remote --remote-url https://ftp.drupal.org/files/projects/dr

# Should start up successfully
cd drupal7
cp -f ../../.lando.upstream.yml .lando.upstream.yml && cat .lando.upstream.yml
cp -f ../.lando.upstream.yml .lando.upstream.yml && cat .lando.upstream.yml
lando start
```

Expand All @@ -32,16 +32,16 @@ Run the following commands to validate things are rolling as they should.
```bash
# Should return the drupal installation page by default
cd drupal7
lando ssh -s appserver -c "curl -L localhost" | grep "Drupal 7"
lando exec appserver -- curl -L localhost | grep "Drupal 7"

# Should use 7.4 as the default php version
cd drupal7
lando php -v | grep "PHP 7.4"

# Should be running apache 2.4 by default
cd drupal7
lando ssh -s appserver -c "apachectl -V | grep 2.4"
lando ssh -s appserver -c "curl -IL localhost" | grep Server | grep 2.4
lando exec appserver -- apachectl -V | grep 2.4
lando exec appserver -- curl -IL localhost | grep Server | grep 2.4

# Should be running mysql 5.7 by default
cd drupal7
Expand Down Expand Up @@ -69,12 +69,13 @@ lando drush eval "phpinfo();" | grep memory_limit | grep -e "-1"

# Should have SIMPLETEST envvars set correctly
cd drupal7
lando ssh -s appserver -c "env" | grep SIMPLETEST_BASE_URL | grep "https://appserver"
lando ssh -s appserver -c "env" | grep SIMPLETEST_DB | grep "mysql://drupal7:drupal7@database/drupal7"
lando exec appserver -- env | grep SIMPLETEST_BASE_URL | grep "https://appserver"
lando exec appserver -- env | grep SIMPLETEST_DB | grep "mysql://drupal7:drupal7@database/drupal7"

# Should have proxy urls present in lando info
cd drupal7
lando info |grep "lando-drupal7.lndo.site"
lando info | grep "lando-drupal7.lndo.site"
lando info | grep "another.lando-drupal7.lndo.site"

# Should be able to pipe data directly into lando drush sql-cli
cd drupal7
Expand Down

0 comments on commit 7b5737e

Please sign in to comment.