-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed/unexpected location behavior #38
Comments
The unit tests load fixtures from arbitrary locations that are not named "drush" or "sites": https://github.com/consolidation/site-alias/blob/master/tests/SiteAliasFileLoaderTest.php#L55 Given this, it is unclear to me what relationship the conditional in |
The default location for site aliases is .drush/sites, if you wouldn't exclude sites then that all aliases would be @sites.site.env |
Oh, right, for the group code. I thought this was just about discoverability. If the Site Alias library thinks the alias name is |
Ah, maybe that is the actual regression here, that this doesn't work anymore? Might be filtered out too eary. |
Yeah, maybe; in theory, group stripping should not be critical. If we did want it to happen for folders other than Let's first see if we can figure out why the group-free alias is not found. The first question is whether or not there is one or more |
Hm, I think I just figured out the real regression here compare to Drupal 8 and maybe earlier versions. It's that it doesn't like . in the "site" part. So with head, drush sa shows (confusingly) the aliases with @site-aliases.foo.master, but both That is, unless your site name contains a ".", e.g. a domain, which I have in a lot of my aliases. Then neither They do fail in different ways, without the site-aliases group, it fails in preflight, when it doesn't find the alias:
With site-aliase prefix, it's even more confusing, because it doesn't even see this as an alias and fails with the error that this is not a command:
The second one fails like that because apparently site alias validation is now more strict and it doesn't allow extra . in \Consolidation\SiteAlias\SiteAliasName::isAliasName? That said, doing a return TRUE there then afterwards fails with the same preflight error. So I guess the question is whether or not . are allowed in the site part, and if not, then it should probably fail when aliases define these, or at least show a warning or something? If that is supported, then I think the problem is then in \Consolidation\SiteAlias\SiteAliasName::parse(), which hardcodes that 3 . means the first is the location and then it doesn't match. cc @pjcdawkins |
That said, I still think that the current handling of location in configured folders is pretty confusing and should ignore the configured root folder and not treat it as a location, but it could be argued that this would be a behavior change at this point. |
This is a limitation of the site alias library, which simplified many things from Drush 8 aliases. PRs to add better error handling would be appreciated. e.g. warnings or errors could be raised when alias files containing an extra dot in their name are found. If |
Steps to reproduce
Put xy.site.yml files into a non-default folder, e.g. .drush/site-aliases, which is what https://github.com/platformsh/platformsh-cli defaults to.
Configure drush.yml like this:
Expected behavior
Site aliases are available as
@xy.env
Actual behavior
Site aliases are available as
@site-aliases.xy.env
.The directory name of the file is always considered the location ( site group) *unless it is either .?drush or .?sites.
The question to answer first, is whether not this is expected behaviour. IMHO not, if you configure a folder like /foo then you expect that to behave like default locations and only have a location/group if you put folders inside that.
There are two ways to fix this, the quickfix that adds more hardcoded assumptions would be to special case site-aliases as this is commonly used and was the default location in drush8. But it would only work for that folder name:
Alternatively, we need to cut off the search path from the path before passing it to that method, as it is static and doesn't have access to that information. That's a bit complicated, needs a loop over the search paths and needs to be done in every place that calls SiteAliasName::locationFromPath() (or we change it to locationFromPath($path, $searchPaths)). Would look like this in one example:
Or, the last "solution" is to just document that your custom alias paths must end in drush or sites if you don't want them to become site locations. And tools like .plaform.sh will have to put drush9 aliases in a different place. Which is not a stupid idea FWIW as you wouldn't have a long list of duplicated drush8/drush9 alias files in the same folder (I have 200+ files in that folder, ~100 each)
The text was updated successfully, but these errors were encountered: