Skip to content

Commit

Permalink
Merge pull request #3 from beclab/fix/modify-fields
Browse files Browse the repository at this point in the history
fixed: adjusted the field content of the interface return data
  • Loading branch information
aby913 authored May 17, 2024
2 parents 9432e45 + 4e649ed commit d5e8571
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/modules/backup/v1/backup_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (o *BackupPlan) hasInProgressBackup(ctx context.Context) (bool, error) {
// return nil
// }

func (o *BackupPlan) GetLatest(ctx context.Context, name string) (*ListBackupsDetails, error) {
func (o *BackupPlan) GetLatest(ctx context.Context, name string) (*ResponseDescribeBackup, error) {
bc, err := o.manager.GetBackupConfig(ctx, name)
if err != nil {
return nil, err
Expand All @@ -280,8 +280,9 @@ func (o *BackupPlan) GetLatest(ctx context.Context, name string) (*ListBackupsDe
log.Errorf("convert time to timestamp error: %v", err)
}

rs := ListBackupsDetails{
rs := ResponseDescribeBackup{
Name: name,
BackupPolicies: bc.Spec.BackupPolicy,
SnapshotFrequency: bc.Spec.BackupPolicy.SnapshotFrequency,
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/modules/backup/v1/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ func (h *Handler) list(req *restful.Request, resp *restful.Response) {
return
}

var res []*ListBackupsDetails
var res []*ResponseDescribeBackup

for _, b := range l.Items {
var r *ListBackupsDetails
var r *ResponseDescribeBackup
r, err = NewBackupPlan(owner, h.factory, h.veleroBackupManager).GetLatest(ctx, b.Name)
if err != nil {
log.Warnf("failed to get backup plan %q: %v", b.Name, err)
Expand Down
13 changes: 13 additions & 0 deletions pkg/modules/backup/v1/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ type ResponseDescribeBackup struct {
BackupPolicies *sysv1.BackupPolicy `json:"backupPolicies"`

Snapshots []Snapshot `json:"snapshots,omitempty"`

// new list api fields
SnapshotName string `json:"latestSnapshotName"`

SnapshotFrequency string `json:"snapshotFrequency"`

CreationTimestamp int64 `json:"creationTimestamp,omitempty"`

NextBackupTimestamp *int64 `json:"nextBackupTimestamp,omitempty"`

Phase string `json:"phase,omitempty"`

FailedMessage string `json:"failedMessage,omitempty"`
}

type PostBackupSchedule struct {
Expand Down

0 comments on commit d5e8571

Please sign in to comment.