From 7e972f4cbd269332bf993e853f5a97c3e96188b5 Mon Sep 17 00:00:00 2001 From: Michail Kargakis Date: Wed, 5 Oct 2016 16:33:06 +0200 Subject: [PATCH] kubectl: add watch flag in rollout status --- pkg/kubectl/cmd/rollout/rollout_status.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/cmd/rollout/rollout_status.go b/pkg/kubectl/cmd/rollout/rollout_status.go index 490540bd27..5864458a7c 100644 --- a/pkg/kubectl/cmd/rollout/rollout_status.go +++ b/pkg/kubectl/cmd/rollout/rollout_status.go @@ -31,7 +31,11 @@ import ( var ( status_long = dedent.Dedent(` - Watch the status of current rollout, until it's done.`) + Show the status of the newest rollout. + + By default 'rollout status' will watch the status of the newest rollout + until it's done. If you don't want to wait for the rollout to finish then + you can use --watch=false.`) status_example = dedent.Dedent(` # Watch the rollout status of a deployment kubectl rollout status deployment/nginx`) @@ -45,7 +49,7 @@ func NewCmdRolloutStatus(f *cmdutil.Factory, out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "status (TYPE NAME | TYPE/NAME) [flags]", - Short: "Watch rollout status until it's done", + Short: "Show the status of newest rollout", Long: status_long, Example: status_example, Run: func(cmd *cobra.Command, args []string) { @@ -57,6 +61,7 @@ func NewCmdRolloutStatus(f *cmdutil.Factory, out io.Writer) *cobra.Command { usage := "identifying the resource to get from a server." cmdutil.AddFilenameOptionFlags(cmd, options, usage) + cmd.Flags().BoolP("watch", "w", true, "Watch the status of the newest rollout until it's done.") return cmd } @@ -118,6 +123,11 @@ func RunStatus(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []str return nil } + shouldWatch := cmdutil.GetFlagBool(cmd, "watch") + if !shouldWatch { + return nil + } + // watch for changes to the deployment w, err := r.Watch(rv) if err != nil {