Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I find myself using the '@hostmaster' alias a lot. But those 10 characters become a hassle after a while. I've begin to copy the hostmaster alias file to create an '@d' alias, which is pretty trivial, but allows for saving 9 key presses on each and every call to an Aegir operation from the command-line. I think it's be nice to provide such a shortcut alias by default. I used '@d' in honor of our d() function, but any such short alias would do.
Comment | File | Size | Author |
---|---|---|---|
#17 | provision-shorter_hm_alias-2031397-17.patch | 4.27 KB | ergonlogic |
Comments
Comment #1
ergonlogicActually, come to think of it, it'd be nice to provide front-end fields to allow user-specified aliases to be generated for all Aegir entities.
Comment #2
anarcat CreditAttribution: anarcat commented@hm seems more appropriate... can we put an alias of an alias in an alias? or do we need to make a separate file?
Comment #3
ergonlogicYes... yes, we can. By moving to GROUPNAME.aliases.drushrc.php:
$ cat ../hostmaster.aliases.drushrc.php
We could generalize this, and add a '--drush-aliases' option to provision-save. We could then alter the template to iterate through such a list, adding arbitrary aliases. Down the road we could add a front-end field to allow #1057698: Configurable node title for hosting import (though the discussion in that issue appears to be about something else entirely.)
Comment #4
ergonlogicSo, the first patch adds the ability to specify '--drush_aliases=foo,bar' during provision-save for sites, and has site aliases generated as alias groups. The second (pretty trivial) patch adds the 'hm' alias for hostmaster sites.
Comment #5
anarcat CreditAttribution: anarcat commentedWhy do we need a new template for this? Couldn't we just add this to the Provision_Config_Drushrc_Alias template?
Comment #6
ergonlogicI suppose we could use the same template for both.
Comment #7
ergonlogicNow using the same template.
Comment #8
anarcat CreditAttribution: anarcat commentedthat's not what I mean...
why do we need this at all? Why do we need a new context? Wouldn't the alias's aliases be written along with the others?
Comment #9
ergonlogicWe need the new context in order to write to a new file name.
In IRC discussions, anarcat suggested moving to *.aliases.drushrc.php for platforms and servers too. We'll also need to clean up the old aliases. So bumping to 3.x
Comment #10
anarcat CreditAttribution: anarcat commentedthe reason we need to go to GROUPNAME.aliases is that drush is a little weird: it will *not* look into hostmaster.alias.drushrc.php for a @hm alias, but it will look into hostmaster.aliases.drushrc.php.
Go figure... I would guess this is a performance improvement - so that must also be considered: do we want to sacrifice that performance for convenience?
Comment #11
ergonlogicSo, yeah... it looks like all *.aliases.drushrc.php files are included in every drush command, whereas only the named alias file is loaded.
We don't actually need the group alias functionality, per se. It is designed to run commands against lists of aliases. Perhaps we'd be better off generating additional *.alias.drushrc.php instead. Unfortunately, 'parent' won't work for that, so we'd need to replicate the whole alias in each file. Still, it should be pretty easy, as write_alias() could just iterate over the extra alias names using the same $properties.
Comment #12
anarcat CreditAttribution: anarcat commentedmaybe we could do a require_once() in the alias?
Comment #13
ergonlogicI don't think I understand the suggestion. It's Drush that'll parse any and all *.aliases.drushrc.php files it can find...
Comment #14
anarcat CreditAttribution: anarcat commentedyes, but in hm.alias.drushrc we could just do:
instead of copying the entire content of the alias.
Comment #15
ergonlogicoh, I see. That should work.
Comment #16
ergonlogicActually, come to think of it, I'm not sure why we would do #14, instead of just writing out the alias anew with the alternate name. The attached patch does so, and as a result makes only very minimal changes. I guess we'd need to clean up these extra aliases too.
The
provision-shorter_hm_alias-2031397-4.patch
patch from #4 is still required for this to work with the hostmaster alias.FWIW, I'd still like to squeeze this into 2.x, since I feel that its a significant CLI usability win, and an 'experimental' front-end feature should be pretty easy to write.
Comment #17
ergonlogicHere's a single patch that combines the one in #16 and the one from #4 that adds the '@hm' alias, along with cleanup of these new aliases.
Comment #18
anarcat CreditAttribution: anarcat commentedthe idea of using a require() is that we avoid copying critical credentials in multiple places. the less we write passwords on disk the happier i am.
Comment #19
ergonlogicThere aren't any credentials in hostmaster.alias.drushrc.php...
Comment #20
anarcat CreditAttribution: anarcat commentedfair enough. :P
Comment #21
ergonlogicBoy, it'd be nice to get this into 2.x... Just sayin'...
Comment #22
ergonlogicWell, 7.x-3.x is open for dev, so I'm going to look at merging this.
Comment #23
ergonlogic#1057698: Configurable node title for hosting import used to have this title, but I think it's more appropriate here. The general use-case and proposed solution would allow for any context to have additional aliases generated. Once the Provision component is in, I'll move this over to the Hosting queue for the addition of front-end and IPC components.
Comment #24
ergonlogicgrr, title typo.
Comment #25
ergonlogicMerged the patch form #17 into Provision in dfc48d6. Yay, @hm!
If anyone wants to implement the front-end components to take advantage of this, be my guest.