Consistent backup model types (#1513)
## Description Make the return type of looking up backup models more consistent by always returning pointers to items. This helps avoid some type casting that could occur in some situations and makes the function definition for print more consistent because they will always work with a pointer type ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) * closes #1512 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
80bbbdb87d
commit
cca5759d7f
2
src/cli/utils/testdata/opts.go
vendored
2
src/cli/utils/testdata/opts.go
vendored
@ -408,7 +408,7 @@ func (MockBackupGetter) Backup(
|
||||
return nil, errors.New("unexpected call to mock")
|
||||
}
|
||||
|
||||
func (MockBackupGetter) Backups(context.Context, ...store.FilterOption) ([]backup.Backup, error) {
|
||||
func (MockBackupGetter) Backups(context.Context, ...store.FilterOption) ([]*backup.Backup, error) {
|
||||
return nil, errors.New("unexpected call to mock")
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ func (b Backup) Print(ctx context.Context) {
|
||||
}
|
||||
|
||||
// PrintAll writes the slice of Backups to StdOut, in the format requested by the caller.
|
||||
func PrintAll(ctx context.Context, bs []Backup) {
|
||||
func PrintAll(ctx context.Context, bs []*Backup) {
|
||||
if len(bs) == 0 {
|
||||
print.Info(ctx, "No backups available")
|
||||
return
|
||||
|
||||
@ -27,7 +27,7 @@ var ErrorRepoAlreadyExists = errors.New("a repository was already initialized wi
|
||||
// repository.
|
||||
type BackupGetter interface {
|
||||
Backup(ctx context.Context, id model.StableID) (*backup.Backup, error)
|
||||
Backups(ctx context.Context, fs ...store.FilterOption) ([]backup.Backup, error)
|
||||
Backups(ctx context.Context, fs ...store.FilterOption) ([]*backup.Backup, error)
|
||||
BackupDetails(
|
||||
ctx context.Context,
|
||||
backupID string,
|
||||
@ -232,7 +232,7 @@ func (r repository) Backup(ctx context.Context, id model.StableID) (*backup.Back
|
||||
}
|
||||
|
||||
// backups lists backups in a repository
|
||||
func (r repository) Backups(ctx context.Context, fs ...store.FilterOption) ([]backup.Backup, error) {
|
||||
func (r repository) Backups(ctx context.Context, fs ...store.FilterOption) ([]*backup.Backup, error) {
|
||||
sw := store.NewKopiaStore(r.modelStore)
|
||||
return sw.GetBackups(ctx, fs...)
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ func runBackupListLoadTest(
|
||||
t.Run("backup_list_"+name, func(t *testing.T) {
|
||||
var (
|
||||
err error
|
||||
bs []backup.Backup
|
||||
bs []*backup.Backup
|
||||
labels = pprof.Labels("list_load_test", name)
|
||||
)
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ func (w Wrapper) GetBackup(ctx context.Context, backupID model.StableID) (*backu
|
||||
func (w Wrapper) GetBackups(
|
||||
ctx context.Context,
|
||||
filters ...FilterOption,
|
||||
) ([]backup.Backup, error) {
|
||||
) ([]*backup.Backup, error) {
|
||||
q := &queryFilters{}
|
||||
q.populate(filters...)
|
||||
|
||||
@ -63,12 +63,12 @@ func (w Wrapper) GetBackups(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bs := make([]backup.Backup, len(bms))
|
||||
bs := make([]*backup.Backup, len(bms))
|
||||
|
||||
for i, bm := range bms {
|
||||
b := backup.Backup{}
|
||||
b := &backup.Backup{}
|
||||
|
||||
err := w.GetWithModelStoreID(ctx, model.BackupSchema, bm.ModelStoreID, &b)
|
||||
err := w.GetWithModelStoreID(ctx, model.BackupSchema, bm.ModelStoreID, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user