Skip to content
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

Add volume subpath option #594

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

vvoland
Copy link
Contributor

@vvoland vvoland commented Mar 11, 2024

Only supported in the long syntax.

@vvoland vvoland requested a review from ndeloof as a code owner March 11, 2024 11:06
format/volume.go Outdated
case "ro":
volume.ReadOnly = true
case "rw":
volume.ReadOnly = false
case "nocopy":
volume.Volume = &types.ServiceVolumeVolume{NoCopy: true}
case "subpath":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds a bit weird to me: if we can detect use of subpath here, why not support this syntax ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is to make it consistent with the Docker CLI where we don't support the short syntax, only the long --mount.
We decided to not support it in the short syntax is to avoid growing parsing complexity.

But if compose is fine with that, I'm happy to implement it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, then maybe better have a generic default case rejecting any unsupported attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default branch seems to explicitly ignore the unsupported attributes:

default:
if isBindOption(option) {
setBindOption(volume, option)
}
// ignore unknown options

Also, in this case the option is supported, just not in the short syntax. Returning an "not supported" message could make the user think that it's not supported at all.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does the CLI report attempt to use such an attribute ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLI errors out when an unknown attribute is used in both long and short syntax.

As for the subpath option specifically, it's not handled differently and will error out just the same as an invalid attribute.

$ docker run -v asddd:/v:volume-subpath=sub --rm -it alpine                                                                                                                                                                      
docker: Error response from daemon: invalid mode: volume-subpath=sub.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, then I don't think compose should try to be more clever/friendly here OR subpath should be made an explicit short-syntax feature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Removed the special case for the short syntax.

Only supported in the long syntax.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants