Drupal 10, the latest version of the open-source digital experience platform with even more features, is here.Not having an easy way to alter the alias files that are written to aegir is a huge pain.
The only hook available is hook_hosting_TASK_OBJECT_context_options() which is only available in hostmaster, not provision.
`provision-save` should have a simple _alter() hook that allows any drush file to modify aliases as they are written, without needing to jump through all the hoops of register a service. (EDIT: Even with a service, I can't seem to get it to alter the written alias. It seems to only exist to collect properties from hostmaster.)
I don't know how to do this yet, but I'm going to look into it.
My use case is for provision_git. I am simply trying to hook into the saving of the alias file to write the list of available branches and tags, without having to use the hosting.module API.
I cannot for the life of me figure out a way to do this with the current aegir APIs.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 2358795-provision-save-on-verify.patch | 343 bytes | Jon Pugh |











Comments
Comment #1
Jon PughSome findings..
This is giving me bad flashbacks to almost 3 years ago now, when I first started building devshop's tools.
Comment #2
Jon PughUpdating the title to reflect a possible solution.
Comment #3
Jon PughComment #4
Jon PughComment #5
Jon PughDISCOVERY!
All of the modifications I made take effect when initially creating a platform via hostmaster. (or deleting the alias and re-verifying)
If we change the way provision-verify works to save the alias using the same objects and functions as the initial provision-save, I think we solve most of these problems.
Confirmed that you can use the following to alter the alias, before it is created with:
None of these work once the alias exists. This means adding any hook_alter() to these options will only work before the first save of the alias.
Let's fix this!
Comment #6
Jon PughComment #7
Jon PughThis patch kindof works.
However, if the "default" value of setProperty() is changed, the new default does not get written over the old one.
I guess that's why it's a "default"?
However this defeats my purpose, which is to change properties if needed on verify.
Baby steps.
Comment #8
Jon PughAlso, this just looks weird.
I really hate the d() command, it is incredibly ambiguous and amorphous.
Any tips on how we could do this correctly?
Comment #9
Jon PughOk, I altered setProperty() to have a $force parameter, so that functions can actually set parameters.
It seems to work!
Also added some comments to the function:
Here's what my git service class looks like. This sets the alias property ALTER no matter what!
Comment #10
Jon PughRan through platform and site creation without problems.
I think the only catch here would be that we are calling "provision-save" twice when invoked from hostmaster. I believe this is because there is a pre hosting task hook that runs it before provision-verify. Now that provision-save is included in provision-verify, we can remove this.
Comment #11
helmo CreditAttribution: helmo commentedDo you have a dev branch for this?
Comment #12
Jon PughI do now. :)
2358795-provision-save-on-verify
Comment #15
helmo CreditAttribution: helmo commentedI've merged your commits from 2358795-provision-save-on-verify, do we need anything else here? Please re-open if we do.
Comment #16
helmo CreditAttribution: helmo commentedComment #18
Jon PughOk, so we never did this...
provision-save is invoked from `drush_hosting_task`. This still needs to exist to make sure data is passed from hostmaster...
Not sure why I really need or want provision-save to be invoked on provision-verify like that. It breaks