Skip to content

Commit de09836

Browse files
committed
cli/command/container: inline parseWindowsDevice
It's not parsing anything, so we may as well inline it to be more clear what's done. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d96b786 commit de09836

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

cli/command/container/opts.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,11 @@ func parseDevice(device, serverOS string) (container.DeviceMapping, error) {
997997
case "linux":
998998
return parseLinuxDevice(device)
999999
case "windows":
1000-
return parseWindowsDevice(device)
1000+
// Windows doesn't support mapping, so passing the given value as-is.
1001+
return container.DeviceMapping{PathOnHost: device}, nil
1002+
default:
1003+
return container.DeviceMapping{}, fmt.Errorf("unknown server OS: %s", serverOS)
10011004
}
1002-
return container.DeviceMapping{}, fmt.Errorf("unknown server OS: %s", serverOS)
10031005
}
10041006

10051007
// parseLinuxDevice parses a device mapping string to a container.DeviceMapping struct
@@ -1030,18 +1032,11 @@ func parseLinuxDevice(device string) (container.DeviceMapping, error) {
10301032
dst = src
10311033
}
10321034

1033-
deviceMapping := container.DeviceMapping{
1035+
return container.DeviceMapping{
10341036
PathOnHost: src,
10351037
PathInContainer: dst,
10361038
CgroupPermissions: permissions,
1037-
}
1038-
return deviceMapping, nil
1039-
}
1040-
1041-
// parseWindowsDevice parses a device mapping string to a container.DeviceMapping struct
1042-
// knowing that the target is a Windows daemon
1043-
func parseWindowsDevice(device string) (container.DeviceMapping, error) {
1044-
return container.DeviceMapping{PathOnHost: device}, nil
1039+
}, nil
10451040
}
10461041

10471042
// validateDeviceCgroupRule validates a device cgroup rule string format

0 commit comments

Comments
 (0)