Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wildcard aliases for Drush 8 #4109

Merged
merged 3 commits into from
Jul 3, 2019
Merged

Support wildcard aliases for Drush 8 #4109

merged 3 commits into from
Jul 3, 2019

Conversation

greg-1-anderson
Copy link
Member

@greg-1-anderson greg-1-anderson commented Jun 27, 2019

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

'*':
  host: appserver.${env-name}.8a5311d2-....pantheon.io
  uri: ${env-name}-a-far-off-site-with-no-org.pantheonsite.io
  user: ${env-name}.8a5311d2-....
  ssh:
    options: '-p 2222 -o "AddressFamily inet"'
    tty: false

If this alias is accessed via drush @examplesite.foobar status, then all occurrences of ${env-name} will be replaced with foobar. If there is, in fact, an environment named foobar, 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

  $aliases['examplesite.*'] = array(
    'uri' => '${env-name}-a-far-off-site-with-no-org.pantheonsite.io',
    'remote-host' => 'appserver.${env-name}.8a5311d2-....pantheon.io',
    'remote-user' => '${env-name}.8a5311d2-....',
    'ssh-options' => '-p 2222 -o "AddressFamily inet"',
  );

Wildcard aliases also have the advantage of not needing to be regenerated when the user creates a new environment.

@greg-1-anderson greg-1-anderson force-pushed the wildcard-aliases branch 2 times, most recently from 616271a to 1f6442a Compare June 28, 2019 00:32
@greg-1-anderson greg-1-anderson merged commit 1a00801 into 8.x Jul 3, 2019
geek-merlin pushed a commit to geek-merlin/drush that referenced this pull request Jul 5, 2019
…#4019)

* Return the realpath instead of symlinked path

* drush-ops#4109: Convert symlinked originalCwd to the realpath

* Fix AppVeyor tests

* Fix failing test EnvironmentTest::testExportConfigData()

* Canonicalize originalCwd after it is converted to the realpath
@weitzman weitzman deleted the wildcard-aliases branch December 13, 2019 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant