Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cd describe to show backup configuration #5358

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions internal/cli/cmd/clusterdefinition/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package clusterdefinition
import (
"context"
"fmt"
"github.com/apecloud/kubeblocks/internal/dataprotection/utils/boolptr"
fengluodb marked this conversation as resolved.
Show resolved Hide resolved
"io"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -153,21 +154,25 @@ func showBackupConfig(backupPolicyTemplates []*v1alpha1.BackupPolicyTemplate, ou
}
fmt.Fprintf(out, "Backup Config:\n")
tbl := printer.NewTablePrinter(out)
tbl.SetHeader("AUTO-BACKUP", "BACKUP-SCHEDULE", "BACKUP-METHOD", "BACKUP-RETENTION")
defaultBackupPolicyTemplate := &v1alpha1.BackupPolicyTemplate{}
// if there is only one backup policy template, it will be the default backup policy template
if len(backupPolicyTemplates) == 1 {
defaultBackupPolicyTemplate = backupPolicyTemplates[0]
}
for _, item := range backupPolicyTemplates {
if item.Annotations[dptypes.DefaultBackupPolicyTemplateAnnotationKey] == "true" {
fengluodb marked this conversation as resolved.
Show resolved Hide resolved
defaultBackupPolicyTemplate = item
break
}
}
tbl.SetHeader("BACKUP-METHOD", "ACTION-SET", "SNAPSHOT-VOLUME")
for _, policy := range defaultBackupPolicyTemplate.Spec.BackupPolicies {
for _, schedule := range policy.Schedules {
scheduleEnable := "Disabled"
if schedule.Enabled != nil && *schedule.Enabled {
scheduleEnable = "Enabled"
for _, method := range policy.BackupMethods {
snapshotVolume := "false"
if boolptr.IsSetToTrue(method.SnapshotVolumes) {
snapshotVolume = "true"
}
tbl.AddRow(scheduleEnable, schedule.CronExpression, schedule.BackupMethod, policy.RetentionPeriod)
tbl.AddRow(method.Name, method.ActionSetName, snapshotVolume)
}
}
tbl.Print()
Expand Down
Loading