-
Notifications
You must be signed in to change notification settings - Fork 712
Description
While working on the tests for #4159 I tripped myself a few times over the problem that except for the root redirect of github:jandubois
, all others need to specify a trailing slash to mark them as directories:
❯ l tmpl url github:jandubois//redirect
https://raw.githubusercontent.com/jandubois/jandubois/main/redirect.yaml
❯ l tmpl url github:jandubois//redirect/
https://raw.githubusercontent.com/jandubois/lima/master/templates/default.yaml
Without the trailing slash redirect
is treated as redirect.yaml
and cannot redirect to another repo, even if redirect.yaml
doesn't exist.
If I can accidentally forget to add the slash while working on the tests, then it is very likely that casual users will also run into it1.
I think we can do 2 things to mitigate it:
-
Treat
foo
asfoo/
iffoo.yaml
does not exist (andfoo
has no extension).So we need to make at least a HEAD request for
foo.yaml
, and if that fails we decide that this was meant to look upfoo/.lima.yaml
instead. -
Allow all
*.yaml
references (only in ORG repos?) to be symlinks or redirectsThis has the advantage that the user doesn't have to create extra subdirectories as containers for
.lima.yaml
, as there is likely nothing else in there. Insteadfoo.yaml
could contain the redirect URL (or symlink).
I think (2) is more useful than (1), but if we do (2) and already fetch the file, then we can just do (1) at the same time at no extra cost.
It is just a fallback when foo.yaml
doesn't exist, so the alternatives are either return an error right away, or retry the foo/.lima.yaml
symlink as well.
I think we should implement both (1) and (2). For consistency we should probably also implement them for non-ORG repos, but of course they would only allow symlinks and not redirects to other repos.
Originally posted by @jandubois in #4159 (comment)
Footnotes
-
For similar reasons many websites redirect http://example.com/ to http://example.com (or vice versa). ↩