Repository navigation
Generic multi-apptype support, for #535 - #574
Conversation
d486854 to
a0952ca
Compare
|
|
||
| // AppTypeFuncs struct defines the functions that can be called (if populated) | ||
| // for a given appType. | ||
| type AppTypeFuncs struct { |
There was a problem hiding this comment.
I would be in favor of adding a detect member here. That way, each app type would define logic for how to detect that type of app, so app type detection becomes a matter of looping through AppTypeMatrix and calling the detect() function for each one. The only downside here is that php could be detected for any more-specific PHP applications, so I guess php would just need to be the last item in AppTypeMatrix?
There was a problem hiding this comment.
I like it. I was thinking of a single detector, but this may be a better approach.
| // for each apptype (CMS). | ||
| // Example: AppTypeMatrix["drupal"]["7"] == { settingsCreator etc } | ||
| var AppTypeMatrix = map[string]AppTypeFuncs{ | ||
| "php": AppTypeFuncs{}, |
There was a problem hiding this comment.
For normal PHP applications, since we're not writing a settings file, where would a user look in order to find database connection details? Do we set environment variables that have this information? Or should we have some default place to write this data so that a user can just require_once a file and call it a day?
There was a problem hiding this comment.
The normal way to find out database settings is ddev describe.
There was a problem hiding this comment.
Right. My question is - are we okay explicitly saying that if you don't use one of our predefined app types, you're on your own for database configuration? Or can we help them out a little bit by making the credentials available somewhere in a machine readable way?
There was a problem hiding this comment.
I would say we're not committed to settings config at any point for any of these. Currently we only do it on db import, but I'm in favor of a new command that does it explicitly (if we have that functionality for the given apptype). We have so many internal conflicts on settings.php on Drupal alone that we're quite stretched on how to do it. We haven't sorted out authoritatively what you do if settings.php exists. We create a settings.local.php, but without checking to see if settings.php includes it. And we don't know what to do if there's already a settings.local.php. It's kind of a rathole. Hard to solve for just Drupal.
| } | ||
|
|
||
| // UploadDirFunc returns the upload (public files) directory for the given app | ||
| func UploadDirFunc(l *DdevApp) string { |
There was a problem hiding this comment.
Is there ever a case where we need > 1 upload dir? For instance, if we eventually support Drupal multisite, do we need an upload dir for each site? Would it be worthwhile to make this a list of strings rather than a single value to make it easy to expand in the future?
There was a problem hiding this comment.
I dearly hope we'll never support any kind of multisite, don't think we will.
However, we do have the problem of public and private. We currently have no support at all for Drupal's private files.
I'd say this is probably out of scope for this PR, but it's a good place to think about it anyway.
There was a problem hiding this comment.
FWIW I just got a question about multisite yesterday. I'm in the same boat as @rfay though, I'd prefer not to support it.
There was a problem hiding this comment.
Multisite is so tremendously evil. I've never understood why in the world it cumbers the earth. I discovered back in 4.6 or something that you can't safely upgrade one of your multisites without breaking the others during the code upgrade, and it's never changed. Never have figured out what problem it solves (unless a MB of code is a storage problem for you).
There was a problem hiding this comment.
I don't particularly want to support multisite either, but it was an immediately obvious use for multiple upload dirs. Does changing this function's signature have a bigger impact? Because if it's a simple change, I think it's important to do this now so that we don't have a breaking change later down the road.
There was a problem hiding this comment.
My bet is the problem is not the func's signature, but rather our assumptions in code. You're right to question the assumption, but I don't think we should change it now because I'd rather aim at simple approaches that match our current thinking. For example, I'd expect we'll have a file_upload_dir in the config.yaml before very long at all, that this would return. If we start to make it plural ahead of the thinking, it implies things that aren't true. file_upload_dir could be a yaml array, but I'd rather see us grow into that in a later PR.
The way I see it right now, we're not committing to much with these signatures (although best to have them as good as they can be). It's not a lot of work to finesse for all the types they represent.
|
|
||
| // GetHookSuggestions gets the actual text of the config.yaml hook suggestions | ||
| // for a given apptype | ||
| func GetHookSuggestions(apptype string) []byte { |
There was a problem hiding this comment.
I'm not super clear on what this returns. Is this something that's going to be different for each app type?
There was a problem hiding this comment.
Ah, I see, looking down at the implementation, this is for suggested hook settings (so drush cr after a db import or whatever). Given that "hook suggestions" is a phrase that has some pretty specific meaning to Drupal developers, can we rename this to something else? Maybe GetSuggestedHooks or GetDefaultHooks or something like that?
188308e to
77ad6cf
Compare
|
I'd like to go head and get this reviewed and in, rather than keep growing it. Hopefully it's not too hard to understand now, but if we do smaller PRs to add to it after it goes in, things will be better.
|
|
@rfay I know that @beeradb left some feedback but given that he and @tannerjfco are out of town this week, I'm assuming you've addressed any nits in a way that you believe Brad would support so that we can make forward progress, correct? |
|
@rickmanelius I'm pretty sure all feedback from Brad and Tanner has been incorporated, except for the things that should be done in additional PRs. |
10104e6 to
76f2d27
Compare
The Problem/Issue/Bug:
We have code scattered all over that does if Drupal7 else if Drupal8 etc. We have to standardize the approach so it's easy to fully support an arbitrary apptype.
How this PR Solves The Problem:
The fundamental approach is in pkg/ddevapp/apptypes.go: A map of apptype->struct-with-funcs is provided, and that routes all custom actions to appropriate actions for the given apptype. Then generic routing functions are used to route through it.
All pkg/cms/* move into pkg/ddevapp as well.
Manual Testing Instructions:
All ddev functionality should work unchanged.
Automated Testing Overview:
Related Issue Link(s):
OP #535
Release/Deployment notes:
There are a number of followup PRs for this, but I think it's important to get this in. Followups include: