Support wildcard aliases for Drush 8 #4109
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On Pantheon, some organizations have many many sites - so many that the operation to generate the Drush aliases for the org can time out and fail.
For Drush 9, site alias wildcard environments can be used to greatly reduce the number of records that need to be generated, as a single record can represent any number of environments for a single site. For example:
examplesite.site.yml
If this alias is accessed via
drush @examplesite.foobar status
, then all occurrences of${env-name}
will be replaced withfoobar
. If there is, in fact, an environment namedfoobar
, then the alias that is generated on-the-fly will work to access the environment. This technique can be used in any instance where the contents of each sites' environments' alias records are identical save for the environment name.This technique may be enhanced with an alias-alter hook to give a user-friendly error message if an environment that does not exist is accessed.
This PR adds wildcard alias handling to Drush 8, which will allow this technique to be used in a more uniform way, e.g. on customer's Drupal 7 sites.
A Drush 8 wildcard alias looks like this:
pantheon.aliases.drushrc.php
Wildcard aliases also have the advantage of not needing to be regenerated when the user creates a new environment.