lando / pantheon

The Official Lando Pantheon plugin.
https://docs.lando.dev/pantheon
GNU General Public License v3.0
12 stars 18 forks source link

Use lookup endpoint in `lando init` when --pantheon-site is set #254

Closed AaronFeledy closed 1 month ago

AaronFeledy commented 3 months ago

When running init for a pantheon recipe, a list of all of the user's sites is fetched and presented to the user so that they can select their site. If a user has many, many thousands of sites, the API call crashes pantheon's terminus endpoint, returning 50x errors, which crashes lando's init process. A user can't use lando init in this situation. Even when specifying the site with the --pantheon-site param, the list of sites is still requested in order to check that the value provided matches a valid site.

This PR add's a parameter to the getSites() method to alter the API request that is used so that the lookup endpoint is used to validate the provided site name rather than comparing against the full list. This improves performance every time the parameter is used, but more importantly, it keeps those with many thousands of sites from experiencing a crash when trying to lando init.

netlify[bot] commented 3 months ago

Deploy Preview for lando-pantheon ready!

Name Link
Latest commit 459e8f1c6a3c4dbbc933da9ccf0733c5dd4d354d
Latest deploy log https://app.netlify.com/sites/lando-pantheon/deploys/670fc429f88562000878dfda
Deploy Preview https://deploy-preview-254--lando-pantheon.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Lighthouse
1 paths audited
Performance: 93 (🟢 up 33 from production)
Accessibility: 98 (no change from production)
Best Practices: 100 (no change from production)
SEO: 86 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

morganestes commented 3 months ago

This worked great for me. We have several thousand sites and were constantly thwarted by the site list even though I knew which one I wanted already.

One thing to note: I tested this on two WordPress sites and the .lando.yml file set them both to Drupal.

 lando init --pantheon-auth="$PANTHEON_TOKEN" --pantheon-site=cool-site --src=pantheon --recipe=pantheon -y
name: cool-site
recipe: pantheon
config:
  framework: drupal
  site: cool-site
  id: uuid-sanitized-for-your-protection
pirog commented 1 month ago

@AaronFeledy this looks good but based on the tests it looks like maybe we are blowing away the "FRAMEWORK" env somehow? I'm investigating and will fix if its quick and easy 😄

AaronFeledy commented 1 month ago

@pirog Yeah, I figure that endpoint I'm using must not return the framework so the "drupal" default is being applied by the plugin.

pirog commented 1 month ago

@AaronFeledy exactly.

i think ive got something we can use that will be "best of both worlds". it wont be quite as fast as yours but will still be a big improvement. standby.