-
Notifications
You must be signed in to change notification settings - Fork 15
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
Enable use of relative volume host-paths #227
Conversation
This avoids ambiguious or erroneous behavior when hostdir is relative and passed to docker: - If it doesn't contain a slash, it is interpreted as a named volume, which is not what the user intended, since it is called "hostpath". - If it does contain a slash, docker aborts and suggests passing an absolute path. See #218.
Note that base_dir is marked Optional[Path] and defaults to None. If a relative path is encountered but base_dir is not given, a ConfigError is raised. This is to support two use cases: 1. Intentionally forbidding the use of relative paths. (This will be used for volume container-paths.) 2. Simplifying tests using programmatic access where base_dir is irrelevant.
I think I want to restrict the relative paths to starting with While the long form is pretty unambiguous (given that it says
The short form is currently (unintentionally, and undocumented) interpreted as a named volume.
Requiring it to start with a I'd rather start with this strict approach and relax as necessary, rather than starting with it loosely defined and trying to tighten it up later. |
This is to avoid ambiguity. #227 (comment)
This is to avoid ambiguity. #227 (comment)
6adb232
to
c7082a2
Compare
I think the behavioral choices here make a lot of sense. I agree that a named volume is not what I would expect from having a bare directory name, and I like that I think in the worst case, this feature will be made less frustrating to an unsuspecting user because of #195. If a non-existent relative host path is created, it will at least be created with permissions such that the user will easily be able to delete it without having to escalate to |
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.
Overall, this looks great. A few small questions and documentation changes are all the useful feedback I can give. I also love the additional documentation on the exceptions that a function can raise! Between that and the new type annotations the codebase is definitely getting easier to spot-check and reason about.
You can thank the Google Python Style Guide for that 😃. (Not all of it I like though...)
Yes! It's so much easier to comprehend, particularly in the case of complex dict or tuple types. Also, With this, and some of the Python 2 tech debt paid off (#226), I'm pretty happy with the codebase these days. |
This will allow us to add additional arguments (e.g., scuba_root). A make_config() wrapper is used in test_scuba.py for simplicity, since existing tests already use kwargs-style call, and moving to the more verbose single-dict argument would increase verbosity unnecessarily.
Starting from load_config(), this passes scuba_root (the directory in which .scuba.yml is found) through the hierarchy to ScubaVolume.from_dict(). This will enable us to use scuba_root in config value expansion, particularly volume paths. Note that scuba_root is marked Optional[Path] to support an empty or default ScubaConfig, or one that is programatically created without a scuba_root directory. This must be accounted for when it is used.
When a relative path is used in a volume hostpath field, it is now considered relative to scuba_root, the directory in which .scuba.yml is found. Fixes #218
This also adds a relative path volume to the example. This also changes the description to only reference Docker bind-mounts since that's all Scuba currently supports (and will likely ever support).
This is to avoid ambiguity. #227 (comment)
This helps when comparing paths that include . and ..
c7082a2
to
d4a61bc
Compare
Thanks for the thorough review @xanarin! |
Unfortunately, this MR introduced a regression in some code I was recently reviewing. We had projects written in Go that were storing their For what it's worth, I'm not in support of this usage of As I understand the usage, the intent was to mount the named volume at ENV GOMODCACHE /go/pkg/mod/cache # requires scuba 2.10.0
volumes:
${HOME}/.cache/go-build: ${HOME}/.cache/go-build
/go/pkg/mod/cache: go-mod-cache |
Well that will teach me not to assume I understand my users.
Whew, looks like this was a good idea. Thanks for pointing this out. I'll open a bug to track the fix. |
Opened #248. |
This enables the use of relative paths in a volume hostpath.
Previously, if one put this in
.scuba.yml
:foo
would be interpreted by Docker as a named volume, resulting in an empty directory at/foo
, which is certainly not what the user intended.Or, if one tried to work around that problem and do this:
Then Docker would complain about the use of a relative path (a specifier containing a
/
but not starting with/
), and suggest the use of an absolute path.Now, when scuba encounters a relative path in a volume
hostpath
, it is interpreted as relative to the scuba root (the directory in which.scbua.yml
is found). To avoid ambiguity with the old behavior, relative paths must start with./
or../
.I also considered interpreting relative paths as relative to the current working directory, but that seemed like a much less useful approach:
$PWD/foo
.!from_yaml
(ref).gitconfig
(ref)env_file
(ref)extends.file
(ref)Fixes #218