forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
148 lines (119 loc) · 4.18 KB
/
model.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package internal
import (
"time"
)
// ApplicationName is a Application name
type ApplicationName string
// ApplicationServiceID is an ID of Service defined in Application
type ApplicationServiceID string
// Application represents Application as defined by OSB API.
type Application struct {
Name ApplicationName
Description string
Services []Service
AccessLabel string
}
// Service represents service defined in the application which is mapped to service class in the service catalog.
type Service struct {
ID ApplicationServiceID
Name string
DisplayName string
Description string
LongDescription string
ProviderDisplayName string
Tags []string
Labels map[string]string
//TODO(entry-simplification): this is an accepted simplification until
// explicit support of many APIEntry and EventEntry
APIEntry *APIEntry
EventProvider bool
}
// Entry is a generic type for all type of entries.
type Entry struct {
Type string
}
// APIEntry represents API of the application.
type APIEntry struct {
Entry
GatewayURL string
AccessLabel string
}
// InstanceID is a service instance identifier.
type InstanceID string
// IsZero checks if InstanceID equals zero.
func (id InstanceID) IsZero() bool { return id == InstanceID("") }
// OperationID is used as binding operation identifier.
type OperationID string
// IsZero checks if OperationID equals zero
func (id OperationID) IsZero() bool { return id == OperationID("") }
// InstanceOperation represents single operation.
type InstanceOperation struct {
InstanceID InstanceID
OperationID OperationID
Type OperationType
State OperationState
StateDescription *string
// ParamsHash is an immutable hash for operation parameters
// used to match requests.
ParamsHash string
// CreatedAt points to creation time of the operation.
// Field should be treated as immutable and is responsibility of storage implementation.
// It should be set by storage Insert method.
CreatedAt time.Time
}
// ServiceID is an ID of the Service exposed via Service Catalog.
type ServiceID string
// ServicePlanID is an ID of the Plan of Service exposed via Service Catalog.
type ServicePlanID string
// Namespace is the name of namespace in k8s
type Namespace string
// Instance contains info about Service exposed via Service Catalog.
type Instance struct {
ID InstanceID
ServiceID ServiceID
ServicePlanID ServicePlanID
Namespace Namespace
State InstanceState
ParamsHash string
}
// InstanceCredentials are created when we bind a service instance.
type InstanceCredentials map[string]string
// InstanceBindData contains data about service instance and it's credentials.
type InstanceBindData struct {
InstanceID InstanceID
Credentials InstanceCredentials
}
// OperationState defines the possible states of an asynchronous request to a broker.
type OperationState string
// String returns state of the operation.
func (os OperationState) String() string {
return string(os)
}
const (
// OperationStateInProgress means that operation is in progress
OperationStateInProgress OperationState = "in progress"
// OperationStateSucceeded means that request succeeded
OperationStateSucceeded OperationState = "succeeded"
// OperationStateFailed means that request failed
OperationStateFailed OperationState = "failed"
)
// OperationType defines the possible types of an asynchronous operation to a broker.
type OperationType string
const (
// OperationTypeCreate means creating OperationType
OperationTypeCreate OperationType = "create"
// OperationTypeRemove means removing OperationType
OperationTypeRemove OperationType = "remove"
// OperationTypeUndefined means undefined OperationType
OperationTypeUndefined OperationType = ""
)
// InstanceState defines the possible states of the Instance in the storage.
type InstanceState string
const (
// InstanceStatePending is when provision is in progress
InstanceStatePending InstanceState = "pending"
// InstanceStateFailed is when provision was failed
InstanceStateFailed InstanceState = "failed"
// InstanceStateSucceeded is when provision was succeeded
InstanceStateSucceeded InstanceState = "succeeded"
)