Rewrite default values that are OS dependent

pull/7385/head
Priya Wadhwa 2020-04-06 10:58:54 -07:00
parent d6fb0931c2
commit 3c7c47e1c7
2 changed files with 11 additions and 9 deletions

View File

@ -23,21 +23,22 @@ import (
) )
type rewrite struct { type rewrite struct {
flag string flag string
description string usage string
defaultVal string
} }
// rewriteFlags rewrites flags that are dependent on operating system // rewriteFlags rewrites flags that are dependent on operating system
// for example, for `minikube start`, the description of --driver // for example, for `minikube start`, the usage of --driver
// outputs possible drivers for the operating system // outputs possible drivers for the operating system
func rewriteFlags(command *cobra.Command) error { func rewriteFlags(command *cobra.Command) error {
rewrites := map[string][]rewrite{ rewrites := map[string][]rewrite{
"start": []rewrite{{ "start": []rewrite{{
flag: "driver", flag: "driver",
description: "Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system.", usage: "Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system.",
}, { }, {
flag: "mount-string", flag: "mount-string",
description: "The argument to pass the minikube mount command on start.", usage: "The argument to pass the minikube mount command on start.",
}}, }},
} }
rws, ok := rewrites[command.Name()] rws, ok := rewrites[command.Name()]
@ -49,7 +50,8 @@ func rewriteFlags(command *cobra.Command) error {
if flag == nil { if flag == nil {
return fmt.Errorf("--%s is not a valid flag for %s", r.flag, command.Name()) return fmt.Errorf("--%s is not a valid flag for %s", r.flag, command.Name())
} }
flag.Usage = r.description flag.Usage = r.usage
flag.DefValue = r.defaultVal
} }
return nil return nil
} }

View File

@ -72,7 +72,7 @@ minikube start [flags]
--kvm-qemu-uri string The KVM QEMU connection URI. (kvm2 driver only) (default "qemu:///system") --kvm-qemu-uri string The KVM QEMU connection URI. (kvm2 driver only) (default "qemu:///system")
--memory string Amount of RAM to allocate to Kubernetes (format: <number>[<unit>], where unit = b, k, m or g). --memory string Amount of RAM to allocate to Kubernetes (format: <number>[<unit>], where unit = b, k, m or g).
--mount This will start the mount daemon and automatically mount files into minikube. --mount This will start the mount daemon and automatically mount files into minikube.
--mount-string string The argument to pass the minikube mount command on start. (default "/Users:/minikube-host") --mount-string string The argument to pass the minikube mount command on start.
--nat-nic-type string NIC Type used for host only network. One of Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM, or virtio (virtualbox driver only) (default "virtio") --nat-nic-type string NIC Type used for host only network. One of Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM, or virtio (virtualbox driver only) (default "virtio")
--native-ssh Use native Golang SSH client (default true). Set to 'false' to use the command line 'ssh' command when accessing the docker machine. Useful for the machine drivers when they will not start with 'Waiting for SSH'. (default true) --native-ssh Use native Golang SSH client (default true). Set to 'false' to use the command line 'ssh' command when accessing the docker machine. Useful for the machine drivers when they will not start with 'Waiting for SSH'. (default true)
--network-plugin string The name of the network plugin. --network-plugin string The name of the network plugin.