-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocessor.go
More file actions
55 lines (50 loc) · 1.38 KB
/
Copy pathprocessor.go
File metadata and controls
55 lines (50 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package processor
import (
"context"
"github.com/ottogroup/penelope/pkg/http/auth/model"
"github.com/ottogroup/penelope/pkg/repository"
)
// Arguments for a Processor
type Argument[R any] struct {
Request R
Principal *model.Principal
}
// Operations define operations for processors
type Operation[T, R any] interface {
Process(context.Context, *Argument[T]) (R, error)
}
func isBackupStatusTransitionValid(current repository.BackupStatus, new repository.BackupStatus) (isValid bool) {
switch current {
case repository.NotStarted:
switch new {
case repository.Prepared, repository.Finished, repository.Paused, repository.ToDelete, repository.BackupDeleted:
isValid = true
}
case repository.Prepared:
switch new {
case repository.NotStarted, repository.Finished, repository.Paused, repository.ToDelete, repository.BackupDeleted:
isValid = true
}
case repository.Finished:
switch new {
case repository.NotStarted, repository.Paused, repository.ToDelete, repository.BackupDeleted:
isValid = true
}
case repository.Paused:
switch new {
case repository.NotStarted, repository.ToDelete, repository.BackupDeleted:
isValid = true
}
case repository.ToDelete:
switch new {
case repository.NotStarted, repository.BackupDeleted:
isValid = true
}
case repository.BackupDeleted:
switch new {
case repository.NotStarted:
isValid = true
}
}
return isValid
}