Repository navigation
Conversation
ShortSyntax renders a volume as `[SOURCE:]TARGET[:OPTIONS]` when some spelling of it parses back as the very same volume, and IsShortSyntaxExpressible reports it. A volume the short syntax has no place for (tmpfs, image, subpath, labels, consistency, extensions, a bind that doesn't create its host path or is recursive...) or would read otherwise (a colon in a path, a bind source that is not a path, a one letter volume name read as a drive) is not expressible, and can only be written in the long syntax. It lets an implementation decide, without guessing from each option, which volumes it can hand over as a plain string (the `Binds` of the Docker API) and which need more. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does, in one sentence
Adds
format.IsShortSyntaxExpressible, which tells whether a volume can be written as a plain[SOURCE:]TARGET[:OPTIONS]string and mean exactly the same thing.Context
volumesentries come in two syntaxes, and an implementation that hands them to an engine has to know which ones it can send as a string (theBindsof the Docker API) and which need more (the Mount API). Today each implementation guesses it option by option: Docker Compose keeps a list of the options that force the Mount API, and a volume nobody listed (for instance a target containing a colon, docker/compose#12993) silently takes the wrong path or is misread. The answer is a property of the volume, and it is the parser's to give.What the PR brings
format.ShortSyntax(v)renders the volume in the short syntax and reports whether it could;format.IsShortSyntaxExpressible(v)is the boolean. A volume is expressible when some spelling of it parses back, withParseVolume, as the very same volume, so the answer cannot drift from the parser.z/Z/propagation on a named volume are expressible, as the parser puts them in the volume's bind.This is deliberately small and independent of the
mountsproposal in #979, so the check can be used, and discussed, on its own.🤖 Generated with Claude Code