From 47f8eb5f9beffcb4a17bb8e0619fbea1202ecf19 Mon Sep 17 00:00:00 2001 From: allenxu404 Date: Fri, 30 Sep 2022 17:30:18 +0800 Subject: [PATCH] Change B/R describe cli to support kopia Signed-off-by: allenxu404 --- changelogs/unreleased/5412-allenxu404 | 1 + pkg/cmd/util/output/backup_describer.go | 15 ++++++++++++--- pkg/cmd/util/output/restore_describer.go | 15 ++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/5412-allenxu404 diff --git a/changelogs/unreleased/5412-allenxu404 b/changelogs/unreleased/5412-allenxu404 new file mode 100644 index 000000000..3258f8c14 --- /dev/null +++ b/changelogs/unreleased/5412-allenxu404 @@ -0,0 +1 @@ +Change B/R describe CLI to support Kopia \ No newline at end of file diff --git a/pkg/cmd/util/output/backup_describer.go b/pkg/cmd/util/output/backup_describer.go index f8c05c156..a6a2f6f99 100644 --- a/pkg/cmd/util/output/backup_describer.go +++ b/pkg/cmd/util/output/backup_describer.go @@ -403,10 +403,19 @@ func failedDeletionCount(requests []velerov1api.DeleteBackupRequest) int { // DescribePodVolumeBackups describes pod volume backups in human-readable format. func DescribePodVolumeBackups(d *Describer, backups []velerov1api.PodVolumeBackup, details bool) { - if details { - d.Printf("Restic Backups:\n") + // Get the type of pod volume uploader. Since the uploader only comes from a single source, we can + // take the uploader type from the first element of the array. + var uploaderType string + if len(backups) > 0 { + uploaderType = backups[0].Spec.UploaderType } else { - d.Printf("Restic Backups (specify --details for more information):\n") + return + } + + if details { + d.Printf("%s Backups:\n", uploaderType) + } else { + d.Printf("%s Backups (specify --details for more information):\n", uploaderType) } // separate backups by phase (combining and New into a single group) diff --git a/pkg/cmd/util/output/restore_describer.go b/pkg/cmd/util/output/restore_describer.go index 286467d03..f6b5f2b37 100644 --- a/pkg/cmd/util/output/restore_describer.go +++ b/pkg/cmd/util/output/restore_describer.go @@ -205,10 +205,19 @@ func describeRestoreResult(d *Describer, name string, result pkgrestore.Result) // describePodVolumeRestores describes pod volume restores in human-readable format. func describePodVolumeRestores(d *Describer, restores []velerov1api.PodVolumeRestore, details bool) { - if details { - d.Printf("Restic Restores:\n") + // Get the type of pod volume uploader. Since the uploader only comes from a single source, we can + // take the uploader type from the first element of the array. + var uploaderType string + if len(restores) > 0 { + uploaderType = restores[0].Spec.UploaderType } else { - d.Printf("Restic Restores (specify --details for more information):\n") + return + } + + if details { + d.Printf("%s Restores:\n", uploaderType) + } else { + d.Printf("%s Restores (specify --details for more information):\n", uploaderType) } // separate restores by phase (combining and New into a single group)