-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 --device support for Windows #1606
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1606 +/- ##
==========================================
- Coverage 56.11% 56.11% -0.01%
==========================================
Files 306 306
Lines 20909 20931 +22
==========================================
+ Hits 11734 11746 +12
- Misses 8328 8337 +9
- Partials 847 848 +1 |
@thaJeztah Could you ping some relevant folks to look at this? |
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.
LGTM
case "linux": | ||
return validateLinuxPath(val, validDeviceMode) | ||
case "windows": | ||
// Windows does validation entirely server-side |
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.
👍 We should remove more of these validations from the client, and defer as much as possible to the daemon/api. Doing so is much more maintainable, and makes sure that the daemon is in charge as to "what's valid" and "what not" (which may differ between daemon versions). I'll start working on an epic for that
@@ -60,7 +60,7 @@ func NewCreateCommand(dockerCli command.Cli) *cobra.Command { | |||
} | |||
|
|||
func runCreate(dockerCli command.Cli, flags *pflag.FlagSet, opts *createOptions, copts *containerOptions) error { | |||
containerConfig, err := parse(flags, copts) | |||
containerConfig, err := parse(flags, copts, dockerCli.ServerInfo().OSType) |
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.
For other reviewers; I was discussing some options with @jhowardmsft - it's a bit ugly, but we should (see my other comment) move more of these platform-specific validations out of the CLI. The cli should limit validation to "well-formedness" of values (e.g. if we expect an integer; validate it's an integer), but (if possible) nothing further than that.
@jhowardmsft as a follow-up, could you help write a short example for the reference documentation? https://github.com/docker/cli/blob/master/docs/reference/commandline/run.md#add-host-device-to-container---device I'm not exactly sure what the format looks like for adding a device on Windows (or when using LCOW), so if you could show an example, that would be great! (I see there's some examples in the blog post at https://blogs.technet.microsoft.com/virtualization/2018/08/13/bringing-device-support-to-windows-server-containers/), perhaps you can take some of that |
LGTM (not a maintainer) |
ping @docker/core-cli-maintainers ptal |
@jhowardmsft needs a rebase @silvin-lubecki PTAL |
Adds support for --device in Windows. This must take the form of: --device='class/clsid'. See this post for more information: https://blogs.technet.microsoft.com/virtualization/2018/08/13/bringing-device-support-to-windows-server-containers/ Signed-off-by: John Howard <jhoward@microsoft.com>
@thaJeztah Yes, that's rebased now. |
@silvin-lubecki PTAL |
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.
LGTM, thank you @jhowardmsft !
And as @thaJeztah said, it would be great to update the documentation too in a followup.
Any update on When Docker CLI v19.03.0 will be out? |
dates are mentioned here; https://github.com/docker/docker-ce/milestone/32 |
Signed-off-by: John Howard jhoward@microsoft.com
Adds support for --device in Windows. This must take the form of: --device='class/clsid'. See https://blogs.technet.microsoft.com/virtualization/2018/08/13/bringing-device-support-to-windows-server-containers/ for more info. The server-side fix was merged in moby/moby#37638 back in November 2018.
@thaJeztah As discussed offline. Annoyingly, due to the code pattern having flag validation happening before the _ping is sent to the daemon, I had to move the validation in the Linux case to during parsing. i.e. after the server OS is known. Fortunately, that avoided the need for a global as was the option on the table before. If (at a later time), the device can be validated entirely daemon side for Linux, it will greatly simplify things.
This replaces #1290. @jterry75 FYI. You should be able to close the previous PR.