forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext.go
51 lines (45 loc) · 1.94 KB
/
ext.go
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
package storage
import (
"github.com/kyma-project/kyma/components/remote-environment-broker/internal"
)
// RemoteEnvironment is an interface that describe storage layer operations for Charts
type RemoteEnvironment interface {
Upsert(re *internal.RemoteEnvironment) (bool, error)
Get(name internal.RemoteEnvironmentName) (*internal.RemoteEnvironment, error)
FindAll() ([]*internal.RemoteEnvironment, error)
FindOneByServiceID(id internal.RemoteServiceID) (*internal.RemoteEnvironment, error)
Remove(name internal.RemoteEnvironmentName) error
}
// Instance is an interface that describe storage layer operations for Instances
type Instance interface {
Insert(i *internal.Instance) error
Remove(id internal.InstanceID) error
Get(id internal.InstanceID) (*internal.Instance, error)
FindOne(func(i *internal.Instance) bool) (*internal.Instance, error)
UpdateState(iID internal.InstanceID, state internal.InstanceState) error
}
// InstanceOperation is an interface that describe storage layer operations for InstanceOperations
type InstanceOperation interface {
// Insert is inserting object into storage.
// Object is modified by setting CreatedAt.
Insert(*internal.InstanceOperation) error
Get(internal.InstanceID, internal.OperationID) (*internal.InstanceOperation, error)
GetAll(internal.InstanceID) ([]*internal.InstanceOperation, error)
UpdateState(internal.InstanceID, internal.OperationID, internal.OperationState) error
UpdateStateDesc(internal.InstanceID, internal.OperationID, internal.OperationState, *string) error
Remove(internal.InstanceID, internal.OperationID) error
}
// IsNotFoundError checks if given error is NotFound error
func IsNotFoundError(err error) bool {
nfe, ok := err.(interface {
NotFound() bool
})
return ok && nfe.NotFound()
}
// IsAlreadyExistsError checks if given error is AlreadyExist error
func IsAlreadyExistsError(err error) bool {
aee, ok := err.(interface {
AlreadyExists() bool
})
return ok && aee.AlreadyExists()
}