-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
--embed
with no alias drops the parent directory from the embedded files
#202
Comments
The logic is a carryover from Matthew's prototype module https://github.com/mholt/caddy-embed. He lays out the reasoning for that part in the README under the Site Root section. |
Hmm, yeah, I think the reason for this is to make it so that URI paths don't have to contain a subfolder. The problem is that without the way we do it, you have to have a subfolder like I mean, if this is truly a problem I am open to changing things, I just figured people would want the option to choose whether a subfolder was required or not. |
I think using |
Thanks for the context! Right, I see how this came to behave the way it does. To be clear, I was motivated to ask about it from a UX perspective (especially as a divergence from Given all that, and that the alias syntax for the Want me to send a tiny docs PR based on this discussion? |
Yes a simple PR would be accepted! Thank you! |
Did wordsmithing here: #206. Whether or not the PR goes in, I consider this issue resolved. Thanks! |
When
xcaddy
is invoked with an--embed
target without an alias, referring to a directory within the working directory, like so:…this results in the
files/
directory of Caddy's embedded FS containing the contents ofmy-dir/
, as thoughmy-dir/*
were the target, rather than afiles/my-dir/
directory containing the contents ofmy-dir
.This behavior was unexpected for me because it diverges from the way that the
go:embed
directive of the Go tool treats its path arguments. Go will embed a specified directory (without a glob suffix) as a directory, and any specified subdirectories will preserve the entire directory structure that leads to that subdirectory. I.e.,go:embed my-dir
creates an embedded directorymy-dir
, andgo:embed dir-a/dir-b
creates an embedded directory structure ofdir-a/dir-b
.This behavior results from this line:
xcaddy/environment.go
Line 96 in b72e330
where
d.Name
is empty if there was no alias in the corresponding argument to--embed
.I see how this could be the intended design for
--embed
, and I also realize that the argument to--embed
must not be treated identically as the arguments to ago:embed
directive, since relative path elements like..
are permitted in--embed
arguments for greater flexibility. If this is the case, I think this behavior should be specified in the--embed
documentation.If it's not the intended design, I suggest that an unaliased path passed to
--embed
that points to a directory should use the last directory name as the copy target when creating the entry in the embeddedfiles/
dir. I.e.,--embed ../other-dir/my-dir
->files/my-dir
.Either way, I'm happy to submit the patch. (I've been tinkering with
--embed
on a fork already.)Thanks!
The text was updated successfully, but these errors were encountered: