Code review comments

pull/7385/head
Priya Wadhwa 2020-04-06 10:26:16 -07:00
parent 4de1197927
commit ff65422562
31 changed files with 17 additions and 118 deletions

View File

@ -59,11 +59,13 @@ func DocForCommand(command *cobra.Command) (string, error) {
if err := generateTitle(command, buf); err != nil {
return "", errors.Wrap(err, "generating title")
}
if err := rewriteFlags(command); err != nil {
return "", errors.Wrap(err, "rewriting flags")
}
if err := writeSubcommands(command, buf); err != nil {
return "", errors.Wrap(err, "writing subcommands")
}
edited := removeHelpText(buf)
return rewriteFlags(command, edited), nil
return removeHelpText(buf), nil
}
// after every command, cobra automatically appends

View File

@ -18,9 +18,6 @@ package generate
var title = `---
title: "{{.Command}}"
linkTitle: "{{.Command}}"
weight: 1
date: {{.Date}}
description: >
{{.Description}}
---

View File

@ -17,7 +17,7 @@ limitations under the License.
package generate
import (
"strings"
"fmt"
"github.com/spf13/cobra"
)
@ -30,42 +30,26 @@ type rewrite struct {
// rewriteFlags rewrites flags that are dependent on operating system
// for example, for `minikube start`, the description of --driver
// outputs possible drivers for the operating system
func rewriteFlags(command *cobra.Command, contents string) string {
func rewriteFlags(command *cobra.Command) error {
rewrites := map[string][]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.",
}, {
flag: "--mount-string",
flag: "mount-string",
description: "The argument to pass the minikube mount command on start.",
}},
}
rws, ok := rewrites[command.Name()]
if !ok {
return contents
return nil
}
for _, r := range rws {
contents = rewriteFlag(contents, r.flag, r.description)
}
return contents
}
func rewriteFlag(contents, flag, description string) string {
lines := strings.Split(contents, "\n")
for i, l := range lines {
if strings.Contains(l, flag) {
// docs start with a prefix of 6 spaces
replacement := " "
replacement += flag
// there are 36 spaces between the start of the flag name
// and the description
spacesBetween := 36 - len(flag)
for i := 0; i < spacesBetween; i++ {
replacement += " "
}
replacement += description
lines[i] = replacement
flag := command.Flag(r.flag)
if flag == nil {
return fmt.Errorf("--%s is not a valid flag for %s", r.flag, command.Name())
}
flag.Usage = r.description
}
return strings.Join(lines, "\n")
return nil
}

View File

@ -1,8 +1,5 @@
---
title: "addons"
linkTitle: "addons"
weight: 1
date: 2020-04-02
description: >
Modify minikube's kubernetes addons
---

View File

@ -1,8 +1,5 @@
---
title: "cache"
linkTitle: "cache"
weight: 1
date: 2020-04-02
description: >
Add or delete an image from the local cache.
---

View File

@ -1,8 +1,5 @@
---
title: "completion"
linkTitle: "completion"
weight: 1
date: 2020-04-02
description: >
Outputs minikube shell completion for the given shell (bash or zsh)
---

View File

@ -1,8 +1,5 @@
---
title: "config"
linkTitle: "config"
weight: 1
date: 2020-04-02
description: >
Modify minikube config
---

View File

@ -1,8 +1,5 @@
---
title: "dashboard"
linkTitle: "dashboard"
weight: 1
date: 2020-04-02
description: >
Access the kubernetes dashboard running within the minikube cluster
---

View File

@ -1,8 +1,5 @@
---
title: "delete"
linkTitle: "delete"
weight: 1
date: 2020-04-02
description: >
Deletes a local kubernetes cluster
---

View File

@ -1,8 +1,5 @@
---
title: "docker-env"
linkTitle: "docker-env"
weight: 1
date: 2020-04-02
description: >
Sets up docker env variables; similar to '$(docker-machine env)'
---

View File

@ -1,8 +1,5 @@
---
title: "help"
linkTitle: "help"
weight: 1
date: 2020-04-02
description: >
Help about any command
---

View File

@ -1,8 +1,5 @@
---
title: "ip"
linkTitle: "ip"
weight: 1
date: 2020-04-02
description: >
Retrieves the IP address of the running cluster
---

View File

@ -1,8 +1,5 @@
---
title: "kubectl"
linkTitle: "kubectl"
weight: 1
date: 2020-04-02
description: >
Run kubectl
---

View File

@ -1,8 +1,5 @@
---
title: "logs"
linkTitle: "logs"
weight: 1
date: 2020-04-02
description: >
Gets the logs of the running instance, used for debugging minikube, not user code.
---

View File

@ -1,8 +1,5 @@
---
title: "mount"
linkTitle: "mount"
weight: 1
date: 2020-04-02
description: >
Mounts the specified directory into minikube
---

View File

@ -1,8 +1,5 @@
---
title: "node"
linkTitle: "node"
weight: 1
date: 2020-04-02
description: >
Node operations
---

View File

@ -1,8 +1,5 @@
---
title: "options"
linkTitle: "options"
weight: 1
date: 2020-04-02
description: >
Show a list of global command-line options (applies to all commands).
---

View File

@ -1,8 +1,5 @@
---
title: "pause"
linkTitle: "pause"
weight: 1
date: 2020-04-02
description: >
pause containers
---

View File

@ -1,8 +1,5 @@
---
title: "podman-env"
linkTitle: "podman-env"
weight: 1
date: 2020-04-02
description: >
Sets up podman env variables; similar to '$(podman-machine env)'
---

View File

@ -1,8 +1,5 @@
---
title: "profile"
linkTitle: "profile"
weight: 1
date: 2020-04-02
description: >
Profile gets or sets the current minikube profile
---

View File

@ -1,8 +1,5 @@
---
title: "service"
linkTitle: "service"
weight: 1
date: 2020-04-02
description: >
Gets the kubernetes URL(s) for the specified service in your local cluster
---

View File

@ -1,8 +1,5 @@
---
title: "ssh-key"
linkTitle: "ssh-key"
weight: 1
date: 2020-04-02
description: >
Retrieve the ssh identity key path of the specified cluster
---

View File

@ -1,8 +1,5 @@
---
title: "ssh"
linkTitle: "ssh"
weight: 1
date: 2020-04-02
description: >
Log into or run a command on a machine with SSH; similar to 'docker-machine ssh'
---

View File

@ -1,8 +1,5 @@
---
title: "start"
linkTitle: "start"
weight: 1
date: 2020-04-02
description: >
Starts a local kubernetes cluster
---
@ -30,7 +27,7 @@ minikube start [flags]
--apiserver-names stringArray A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine
--apiserver-port int The apiserver listening port (default 8443)
--auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true)
--driver Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system.
--cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none. (default true)
--container-runtime string The container runtime to be used (docker, crio, containerd). (default "docker")
--cpus int Number of CPUs allocated to Kubernetes. (default 2)
--cri-socket string The cri socket path to be used.
@ -42,7 +39,7 @@ minikube start [flags]
--docker-env stringArray Environment variables to pass to the Docker daemon. (format: key=value)
--docker-opt stringArray Specify arbitrary flags to pass to the Docker daemon. (format: key=value)
--download-only If true, only download and cache files for later use - don't install or start anything.
--driver Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system.
--driver string Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system.
--dry-run dry-run mode. Validates configuration, but does not mutate system state
--embed-certs if true, will embed the certs in kubeconfig.
--enable-default-cni Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with "--network-plugin=cni".
@ -75,7 +72,7 @@ minikube start [flags]
--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).
--mount This will start the mount daemon and automatically mount files into minikube.
--mount-string The argument to pass the minikube mount command on start.
--mount-string string The argument to pass the minikube mount command on start. (default "/Users:/minikube-host")
--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)
--network-plugin string The name of the network plugin.

View File

@ -1,8 +1,5 @@
---
title: "status"
linkTitle: "status"
weight: 1
date: 2020-04-02
description: >
Gets the status of a local kubernetes cluster
---

View File

@ -1,8 +1,5 @@
---
title: "stop"
linkTitle: "stop"
weight: 1
date: 2020-04-02
description: >
Stops a running local kubernetes cluster
---

View File

@ -1,8 +1,5 @@
---
title: "tunnel"
linkTitle: "tunnel"
weight: 1
date: 2020-04-02
description: >
tunnel makes services of type LoadBalancer accessible on localhost
---

View File

@ -1,8 +1,5 @@
---
title: "unpause"
linkTitle: "unpause"
weight: 1
date: 2020-04-02
description: >
unpause Kubernetes
---

View File

@ -1,8 +1,5 @@
---
title: "update-check"
linkTitle: "update-check"
weight: 1
date: 2020-04-02
description: >
Print current and latest version number
---

View File

@ -1,8 +1,5 @@
---
title: "update-context"
linkTitle: "update-context"
weight: 1
date: 2020-04-02
description: >
Verify the IP address of the running cluster in kubeconfig.
---

View File

@ -1,8 +1,5 @@
---
title: "version"
linkTitle: "version"
weight: 1
date: 2020-04-02
description: >
Print the version of minikube
---