In Aegir's dev-services branch, we are dumping a bunch of configuration in site aliases. This works great locally, but they aren't passed on to remote servers. This patch merges in the alias's options.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | remote_alias_options-2.patch | 2.62 KB | greg.1.anderson |
| #10 | drush.patch | 2.49 KB | drumm |
| #5 | drush.patch | 2.54 KB | drumm |
| #3 | drush.patch | 1.97 KB | drumm |
| drush.patch | 1.12 KB | drumm |
Comments
Comment #1
greg.1.anderson commentedI have some reservations about this. Are remote-host and remote-user the only alias options that should not be propagated by drush_redispatch_get_option?
In drush-4.x, I think that we need to be able to clearly differentiate which alias items are options, and which items select the site. I think the proposed patch is probably okay for drush-3, but I'd like comments from Moshe and Adrian first. (Already implicitly approved by Adrian?)
Comment #2
greg.1.anderson commentedOkay, here are my thoughts on this.
drush_sitealias_site_selection_keysthat should return an array containing remote-host, remote-user, uri and root.drush_redispatch_get_optionshould call that function and unset any key thereby returned in $options.drush_redispatch_get_optionshould also unset command-specific and path-aliases.Try out those changes; if it works for Aegir, then I think it would be ready to commit to the drush-3 branch too.
Comment #3
drummOk, updated patch attached.
I added 'name' to drush_sitealias_site_selection_keys().
I didn't add uri and root, since they are needed to find the remote Drupal installation. Unless I am missing some other way they are passed.
It is working for Aegir so far.
Comment #4
greg.1.anderson commentedEvery function that calls drush_redispatch_get_options should set uri and root. Sometimes they will be set to the same value as what is in the alias context, but in some instances they might not be, and it would be destructive to overwrite them. If you add 'uri' and 'root' to drush_sitealias_site_selection_keys, then I think the code looks pretty good.
Do let me know if that addition causes any problem for Aegir; it should still work, because 'uri' and 'root' should always be set. If they are not set because you are calling drush_redispatch_get_options directly from some Aegir function, then perhaps you should instead be calling drush_do_site_command with the alias record for "@self" (pass the result of drush_redispatch_get_options in as the 'data' argument).
Comment #5
drummAha, I was hacking an alias into a call to drush_backend_invoke_args() and letting that sort it out by redispatch. drush_do_site_command() looks a lot cleaner. But that one only copies 'root' and 'uri', not the rest of the alias record. This is not a redispatch, it has a fresh set of args, data/options, and an alias determined by hostmaster.
I added code to copy over alias-specified options that are not overridden by $data in drush_do_site_command().
Comment #6
greg.1.anderson commentedCode looks good, but I'm not going to be able to test it until later.
Comment #7
drummUnlike invoking from bash, drush_do_site_command() doesn't load the options into the 'alias' context. The options are passed as command line arguments. Is there another way commands should be invoked using aliases for more consistent behavior from the Drush API?
Comment #8
moshe weitzman commentedcould be more terse with array_diff()?
otherwise, looks good. greg should test and commit when he is ready.
Comment #9
greg.1.anderson commentedStill catching up on backlog of stuff... feel free to assign issues to me, I'll try to get to these soon.
Comment #10
drummMore-terse version as moshe suggested. array_diff_key() is PHP 5.1+ only.
Comment #11
greg.1.anderson commentedDrush will exit immediately if the php version is less than 5.2, so a php 5.1+ function is okay.
The above patch looks fine by inspection, but I still need to find time to sit down and test this.
Comment #12
greg.1.anderson commented#10 did not work. --root and --uri were not passed to the remote system, causing a bootstrap failure. I'm not sure why; looking at the code, it appears correct, but applying the patch broke remote commands, and removing it made them work again. I'm going to have to look at this more later, no time now.
From a -d run without the patch:
From a -d run with the patch:
Comment #13
greg.1.anderson commentedCommitted the patch below after fixing the problem described in #12. 'root' and 'uri' from the site alias are applied to the options context, not the alias context, so I changed the site-specification stripping code to look like this:
This insures that items that are applied to the options context (e.g. 'root' and 'uri') are still passed on, because if they're in 'options', they're needed for identification in the remote dispatch.