mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-04 12:14:00 +00:00
Add display of resource policies name in describe backup output
Signed-off-by: Ming <mqiu@vmware.com>
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
|
||||
@@ -83,6 +84,11 @@ func DescribeBackup(
|
||||
|
||||
d.Printf("Phase:\t%s%s\n", phaseString, logsNote)
|
||||
|
||||
if backup.Spec.ResourcePolicy != nil {
|
||||
d.Println()
|
||||
DescribeResourcePolicies(d, backup.Spec.ResourcePolicy)
|
||||
}
|
||||
|
||||
status := backup.Status
|
||||
if len(status.ValidationErrors) > 0 {
|
||||
d.Println()
|
||||
@@ -118,6 +124,13 @@ func DescribeBackup(
|
||||
})
|
||||
}
|
||||
|
||||
// DescribeResourcePolicies describes resource policiesin human-readable format
|
||||
func DescribeResourcePolicies(d *Describer, resPolicies *v1.TypedLocalObjectReference) {
|
||||
d.Printf("Resource policies:\n")
|
||||
d.Printf("\tType:\t%s\n", resPolicies.Kind)
|
||||
d.Printf("\tName:\t%s\n", resPolicies.Name)
|
||||
}
|
||||
|
||||
// DescribeBackupSpec describes a backup spec in human-readable format.
|
||||
func DescribeBackupSpec(d *Describer, spec velerov1api.BackupSpec) {
|
||||
// TODO make a helper for this and use it in all the describers.
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
|
||||
@@ -56,6 +57,10 @@ func DescribeBackupInSF(
|
||||
|
||||
d.Describe("phase", backup.Status.Phase)
|
||||
|
||||
if backup.Spec.ResourcePolicy != nil {
|
||||
DescribeResourcePoliciesInSF(d, backup.Spec.ResourcePolicy)
|
||||
}
|
||||
|
||||
status := backup.Status
|
||||
if len(status.ValidationErrors) > 0 {
|
||||
d.Describe("validationErrors", status.ValidationErrors)
|
||||
@@ -503,6 +508,14 @@ func DescribeBackupResultsInSF(ctx context.Context, kbClient kbclient.Client, d
|
||||
}
|
||||
}
|
||||
|
||||
// DescribeResourcePoliciesInSF describes resource policies in structured format.
|
||||
func DescribeResourcePoliciesInSF(d *StructuredDescriber, resPolicies *v1.TypedLocalObjectReference) {
|
||||
policiesInfo := make(map[string]interface{})
|
||||
policiesInfo["type"] = resPolicies.Kind
|
||||
policiesInfo["name"] = resPolicies.Name
|
||||
d.Describe("resourcePolicies", policiesInfo)
|
||||
}
|
||||
|
||||
func describeResultInSF(m map[string]interface{}, result results.Result) {
|
||||
m["velero"], m["cluster"], m["namespace"] = []string{}, []string{}, []string{}
|
||||
|
||||
|
||||
@@ -43,6 +43,11 @@ func DescribeSchedule(schedule *v1.Schedule) string {
|
||||
}
|
||||
d.Printf("Phase:\t%s\n", phaseString)
|
||||
|
||||
if schedule.Spec.Template.ResourcePolicy != nil {
|
||||
d.Println()
|
||||
DescribeResourcePolicies(d, schedule.Spec.Template.ResourcePolicy)
|
||||
}
|
||||
|
||||
status := schedule.Status
|
||||
if len(status.ValidationErrors) > 0 {
|
||||
d.Println()
|
||||
|
||||
Reference in New Issue
Block a user