Closed (fixed)
Project:
Drush
Component:
Base system (internal API)
Priority:
Major
Category:
Feature request
Assigned:
Reporter:
Created:
11 Oct 2010 at 15:33 UTC
Updated:
15 Jan 2011 at 15:10 UTC
Jump to comment: Most recent file
I would like to modify the @self alias to add some options to it. Is that possible? Tried using $aliases['self'] in an aliases file in sites/default, with no luck.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | drush-propagate-site-options.patch | 5.17 KB | greg.1.anderson |
| #11 | drush-command-specific-aliases.patch | 1.76 KB | greg.1.anderson |
| #4 | drush-alias-context.patch | 739 bytes | greg.1.anderson |
Comments
Comment #1
greg.1.anderson commentedI was actually planning on unioning info from an alias in sites/SITENAME/self.alias.drushrc.php (or something equivalent) into @self whenever a site is bootstrapped -- but I have not done so yet.
Comment #2
sharpbites commentedThanks for the super-quick answer. I'll keep an eye on this.
Just to let you know a valid use case for this (although I'm sure you probably already thought of a ton more), this is what I wanted this feature for:
I have a sites/SITENAME/group.aliases.drushrc.php file with @qa and @pro aliases. The file is inside the project so that config is shared between developers. I wanted to modify @self to allow any developer syncing from @pro or @qa to @self without forcing each of them to add a custom alias file for their environment (where root paths differ).
Comment #3
sharpbites commentedI just realized I can work around this using the 'parent' option:
Comment #4
greg.1.anderson commentedRather than modifying the @self alias as suggested in #1, a better thing to do is to just put a drushrc.php config file in the site context. This already works for adding new options to your context.
The enclosed patch reduces the priority of the 'alias' context so that drush and site context options can also override settings in @self.
Comment #5
moshe weitzman commentedI recently had to experiment a bit to settle on this solution. Would be good to more explicitly document how to set options for the 'default' site. i needed it for sql-sync.
On that note, I was wondering how one can set 'command_specific' options in a site alias. Would be good to add an example if thats supported.
Comment #6
moshe weitzman commentedPatch looks good
Comment #7
greg.1.anderson commentedCommitted
Comment #8
moshe weitzman commentedAssigning back to Greg in case we can do something about the documentation requests in #5. If not, please move back to Fixed.
Comment #9
greg.1.anderson commentedI'll document this.
Comment #10
moshe weitzman commentedThanks.
Can one specify $override in a site alias. This overrides drupal's variable_get(). See bottom of example.drushrc.php. If yes, lets document it. If not, consider this a feature request.
Comment #11
greg.1.anderson commentedHere's the documentation for command specific in an alias.
The other two items are feature requests. It turns out that #4 is true in the general case, but not in the case of rsync or sql-sync, as the target sites are not bootstrapped. I'll make sure that their drushrc.php contexts are loaded anyway. $override in alias files is not implemented, but should not be hard.
Comment #12
greg.1.anderson commentedComment #13
moshe weitzman commentedThanks. Looks good. Found two typos
'druch'
'precidence' (twice)
Comment #14
moshe weitzman commentedWe can close this one after the docs go in. I'll open a new issue for overrides and other wishes for drush5.
Comment #15
greg.1.anderson commentedDocs have been committed.
Comment #16
greg.1.anderson commentedI'm re-opening this as a marker. I'm going to try some things; there may be some advantages to modifying @self over placing options in a site's drushrc.php. Maybe I'll re-close without making any changes.
Comment #17
greg.1.anderson commented#4 is not satisfying for a couple of reasons. First, it does not work with sql-sync, so the original request is not met by this workaround. Second, it is important that the alias context have a higher priority than the site context so that you can define special aliases for sites that override the options defined at the site level.
This patch rolls back the context priority change (well, not quite rolls back: command-specific is still a higher-priority context than alias so that command-specific options in aliases override options of the same name in the alias). It also adds a bit of infrastructure so that options set in the drushrc.php file of a site affect sql-sync when an alias for that site is used as a target.
Two changes accomplish this:
1. backend invoke passes the 'self' alias for the completed command back with the other results in the results array. The 'site' context is first merged into the self alias record.
2. drush_sitealias_add_db_settings (called by sql-sync to look up the database settings) will merge the values from the 'self' alias record in the backend invoke results array into the alias record used to fetch the db results.
In this way, sites can define shared settings in a drushrc.php file in the Drupal site folder (same folder as settings.php), and options set there will be applied to sql-sync operations on that site, even remotely.
This needs better docs, which I will provide once the code is RTBC. It's working very well for me, and increases the power of drush quite a bit.
Comment #18
moshe weitzman commentedCode looks good, and I agree that it will be handy. I don't know who will setup a patched remote drush to test this so lets call this RTBC now.
I presume this will only work for the case when db-url is *not* defined in the remote alias. Otherwise, sql-sync would connect to mysql directly and we never get the site context back.
Comment #19
greg.1.anderson commentedYou are correct; if the database info is already available in the alias, then drush will not pick up the site's drushrc.php configuration. Therefore, this is not an alternative to a policy file, it's just a convenience.
Committed.