mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
kubectl: add --revision flag in rollout status
This commit is contained in:
@@ -32,11 +32,14 @@ import (
|
||||
|
||||
var (
|
||||
status_long = dedent.Dedent(`
|
||||
Show the status of the newest rollout.
|
||||
Show the status of the rollout.
|
||||
|
||||
By default 'rollout status' will watch the status of the newest rollout
|
||||
By default 'rollout status' will watch the status of the latest rollout
|
||||
until it's done. If you don't want to wait for the rollout to finish then
|
||||
you can use --watch=false.`)
|
||||
you can use --watch=false. Note that if a new rollout starts in-between, then
|
||||
'rollout status' will continue watching the latest revision. If you want to
|
||||
pin to a specific revision and abort if it is rolled over by another revision,
|
||||
use --revision=N where N is the revision you need to watch for.`)
|
||||
status_example = dedent.Dedent(`
|
||||
# Watch the rollout status of a deployment
|
||||
kubectl rollout status deployment/nginx`)
|
||||
@@ -50,7 +53,7 @@ func NewCmdRolloutStatus(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "status (TYPE NAME | TYPE/NAME) [flags]",
|
||||
Short: "Show the status of newest rollout",
|
||||
Short: "Show the status of the rollout",
|
||||
Long: status_long,
|
||||
Example: status_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
@@ -62,7 +65,8 @@ 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.")
|
||||
cmd.Flags().BoolP("watch", "w", true, "Watch the status of the rollout until it's done.")
|
||||
cmd.Flags().Int64("revision", 0, "Pin to a specific revision for showing its status. Defaults to 0 (last revision).")
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -114,8 +118,13 @@ func RunStatus(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []str
|
||||
return err
|
||||
}
|
||||
|
||||
revision := cmdutil.GetFlagInt64(cmd, "revision")
|
||||
if revision < 0 {
|
||||
return fmt.Errorf("revision must be a positive integer: %v", revision)
|
||||
}
|
||||
|
||||
// check if deployment's has finished the rollout
|
||||
status, done, err := statusViewer.Status(cmdNamespace, info.Name)
|
||||
status, done, err := statusViewer.Status(cmdNamespace, info.Name, revision)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -140,7 +149,7 @@ func RunStatus(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []str
|
||||
return intr.Run(func() error {
|
||||
_, err := watch.Until(0, w, func(e watch.Event) (bool, error) {
|
||||
// print deployment's status
|
||||
status, done, err := statusViewer.Status(cmdNamespace, info.Name)
|
||||
status, done, err := statusViewer.Status(cmdNamespace, info.Name, revision)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user