add help description and examples to wait

pull/8/head
juanvallejo 2018-06-27 14:41:55 -04:00
parent c005b9d0ab
commit 54ddddaa2d
No known key found for this signature in database
GPG Key ID: 7D2C958002D6448D
2 changed files with 27 additions and 1 deletions

View File

@ -6,6 +6,7 @@ go_library(
importpath = "k8s.io/kubernetes/pkg/kubectl/cmd/wait",
visibility = ["//visibility:public"],
deps = [
"//pkg/kubectl/cmd/templates:go_default_library",
"//pkg/kubectl/cmd/util:go_default_library",
"//pkg/kubectl/genericclioptions:go_default_library",
"//pkg/kubectl/genericclioptions/printers:go_default_library",

View File

@ -30,12 +30,35 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/dynamic"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
)
var (
wait_long = templates.LongDesc(`
Experimental: Wait for a specific condition on one or many resources.
The command takes multiple resources and waits until the specified condition
is seen in the Status field of every given resource.
Alternatively, the command can wait for the given set of resources to be deleted
by providing the "delete" keyword as the value to the --for flag.
A successful message will be printed to stdout indicating when the specified
condition has been met. One can use -o option to change to output destination.`)
wait_example = templates.Examples(`
# Wait for the pod "busybox1" to contain the status condition of type "Ready".
kubectl wait --for=condition=Ready pod/busybox1
# Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command.
kubectl delete pod/busybox1
kubectl wait --for=delete pod/busybox1 --timeout=60s`)
)
// WaitFlags directly reflect the information that CLI is gathering via flags. They will be converted to Options, which
// reflect the runtime requirements for the command. This structure reduces the transformation to wiring and makes
// the logic itself easy to unit test
@ -73,7 +96,9 @@ func NewCmdWait(restClientGetter genericclioptions.RESTClientGetter, streams gen
cmd := &cobra.Command{
Use: "wait resource.group/name [--for=delete|--for condition=available]",
DisableFlagsInUseLine: true,
Short: "Experimental: Wait for one condition on one or many resources",
Short: "Experimental: Wait for a specific condition on one or many resources.",
Long: wait_long,
Example: wait_example,
Run: func(cmd *cobra.Command, args []string) {
o, err := flags.ToOptions(args)
cmdutil.CheckErr(err)