From c7dd91faf5ac03ecd7f8632a719036517489fe1b Mon Sep 17 00:00:00 2001 From: Boaz Shuster Date: Tue, 7 Feb 2017 14:52:20 +0200 Subject: [PATCH] Hide command options that are related to Windows Signed-off-by: Boaz Shuster --- command/cli.go | 7 +++++++ command/container/opts.go | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/command/cli.go b/command/cli.go index 782c3a5074..783e516f3d 100644 --- a/command/cli.go +++ b/command/cli.go @@ -51,6 +51,7 @@ type DockerCli struct { keyFile string client client.APIClient hasExperimental bool + osType string defaultVersion string } @@ -59,6 +60,11 @@ func (cli *DockerCli) HasExperimental() bool { return cli.hasExperimental } +// OSType returns the operating system the daemon is running on. +func (cli *DockerCli) OSType() string { + return cli.osType +} + // DefaultVersion returns api.defaultVersion of DOCKER_API_VERSION if specified. func (cli *DockerCli) DefaultVersion() string { return cli.defaultVersion @@ -166,6 +172,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions) error { if ping, err := cli.client.Ping(context.Background()); err == nil { cli.hasExperimental = ping.Experimental + cli.osType = ping.OSType // since the new header was added in 1.25, assume server is 1.24 if header is not present. if ping.APIVersion == "" { diff --git a/command/container/opts.go b/command/container/opts.go index 16bb1aa434..4ce872b556 100644 --- a/command/container/opts.go +++ b/command/container/opts.go @@ -189,6 +189,7 @@ func addFlags(flags *pflag.FlagSet) *containerOptions { flags.Var(&copts.securityOpt, "security-opt", "Security Options") flags.StringVar(&copts.usernsMode, "userns", "", "User namespace to use") flags.StringVar(&copts.credentialSpec, "credentialspec", "", "Credential spec for managed service account (Windows only)") + flags.SetAnnotation("credentialspec", "ostype", []string{"windows"}) // Network and port publishing flag flags.Var(&copts.extraHosts, "add-host", "Add a custom host-to-IP mapping (host:ip)") @@ -239,7 +240,9 @@ func addFlags(flags *pflag.FlagSet) *containerOptions { flags.StringVar(&copts.cpusetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)") flags.StringVar(&copts.cpusetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)") flags.Int64Var(&copts.cpuCount, "cpu-count", 0, "CPU count (Windows only)") + flags.SetAnnotation("cpu-count", "ostype", []string{"windows"}) flags.Int64Var(&copts.cpuPercent, "cpu-percent", 0, "CPU percent (Windows only)") + flags.SetAnnotation("cpu-percent", "ostype", []string{"windows"}) flags.Int64Var(&copts.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period") flags.Int64Var(&copts.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota") flags.Int64Var(&copts.cpuRealtimePeriod, "cpu-rt-period", 0, "Limit CPU real-time period in microseconds") @@ -254,7 +257,9 @@ func addFlags(flags *pflag.FlagSet) *containerOptions { flags.Var(&copts.deviceWriteBps, "device-write-bps", "Limit write rate (bytes per second) to a device") flags.Var(&copts.deviceWriteIOps, "device-write-iops", "Limit write rate (IO per second) to a device") flags.Var(&copts.ioMaxBandwidth, "io-maxbandwidth", "Maximum IO bandwidth limit for the system drive (Windows only)") + flags.SetAnnotation("io-maxbandwidth", "ostype", []string{"windows"}) flags.Uint64Var(&copts.ioMaxIOps, "io-maxiops", 0, "Maximum IOps limit for the system drive (Windows only)") + flags.SetAnnotation("io-maxiops", "ostype", []string{"windows"}) flags.Var(&copts.kernelMemory, "kernel-memory", "Kernel memory limit") flags.VarP(&copts.memory, "memory", "m", "Memory limit") flags.Var(&copts.memoryReservation, "memory-reservation", "Memory soft limit")