-
Notifications
You must be signed in to change notification settings - Fork 235
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
Allow direct mounting directory 'pattern' (plus improve errors) #1488
Conversation
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
f6175d2
to
8e39b54
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this - love the improvement, just some nits on the implementation.
crates/loader/src/local/assets.rs
Outdated
host: path.absolutize()?.into(), | ||
}) | ||
} else { | ||
let typ = if p.contains('*') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an extremely complicated clause, especially at the "an else inside a match inside a map" level of indentation - by the time I get to the end of it I have long since forgotten what I'm doing. Consider pulling out a function e.g. direct_mount_pattern_error(...)
, or even (maybe better) pulling out the whole match arm (starting on line 79) into direct_mount_for_pattern()
.
Or even pulling out the whole map body...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled out the map body into its own function. I hope that that helps!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IT HELPS SO MUCH
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Fixes #1487 and #1356. This PR does the following two things
Direct mounting directory "patterns"
When the
files
option is a directory that exists and--direct-mounts
is passed, we now allow mapping to happen (previously this was an error). Essentially this makesfiles = ["some/directory"]
equivalent tofiles = { source = "some/directory", destination = "some/directory" }
.Better error messages
The error message when using a file or glob pattern together with
--direct-mounts
was the following:This was very confusing especially when using a file path and not glob pattern.
The error message now changes to the following in these various situations:
Glob pattern
Existing file path
Non-existing directory or file path