From 5f463c59ec4753ef09a86411eee08ef5dbcb07a9 Mon Sep 17 00:00:00 2001 From: Qi Xu <107547364+allenxu404@users.noreply.github.com> Date: Wed, 9 Aug 2023 05:16:53 +0800 Subject: [PATCH] add "Deleting" phase for restore display (#6604) Signed-off-by: allenxu404 --- pkg/cmd/cli/restore/get.go | 7 +++++++ pkg/cmd/util/output/restore_describer.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/cmd/cli/restore/get.go b/pkg/cmd/cli/restore/get.go index 74ac42ad3..9a4014b25 100644 --- a/pkg/cmd/cli/restore/get.go +++ b/pkg/cmd/cli/restore/get.go @@ -59,6 +59,13 @@ func NewGetCommand(f client.Factory, use string) *cobra.Command { cmd.CheckError(err) } + // Append "(Deleting)" to phase if deletionTimestamp is marked. + for i := range restores.Items { + if !restores.Items[i].DeletionTimestamp.IsZero() { + restores.Items[i].Status.Phase += " (Deleting)" + } + } + if printed, err := output.PrintWithFormat(c, restores); printed || err != nil { cmd.CheckError(err) return diff --git a/pkg/cmd/util/output/restore_describer.go b/pkg/cmd/util/output/restore_describer.go index 13ac580b5..00d1304dc 100644 --- a/pkg/cmd/util/output/restore_describer.go +++ b/pkg/cmd/util/output/restore_describer.go @@ -45,6 +45,12 @@ func DescribeRestore(ctx context.Context, kbClient kbclient.Client, restore *vel phase = velerov1api.RestorePhaseNew } phaseString := string(phase) + + // Append "Deleting" to phaseString if deletionTimestamp is marked. + if !restore.DeletionTimestamp.IsZero() { + phaseString += " (Deleting)" + } + switch phase { case velerov1api.RestorePhaseCompleted: phaseString = color.GreenString(phaseString)