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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
commonv1 "github.com/johnandersen777/socialweb-computer-kcp/api/common/v1alpha1"
)
type Infra struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec InfraSpec `json:"spec,omitempty"`
Status InfraStatus `json:"status,omitempty"`
}
type InfraList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Infra `json:"items"`
}
type EphemeralInfra struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec EphemeralInfraSpec `json:"spec,omitempty"`
Status EphemeralInfraStatus `json:"status,omitempty"`
}
type EphemeralInfraList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []EphemeralInfra `json:"items"`
}
type InfraSpec struct {
Description string `json:"description,omitempty" apigen:"maxLength=1024"`
Contracts []InfraContract `json:"contracts,omitempty" apigen:"listType=map,listMapKey=name"`
Secrets []InfraContractSecret `json:"secrets,omitempty" apigen:"listType=map,listMapKey=contract"`
Nodes []InfraContractNode `json:"nodes,omitempty" apigen:"listType=map,listMapKey=contract"`
ClusterRef *commonv1.ObjectRef `json:"clusterRef,omitempty"`
Record *InfraRecordBinding `json:"record,omitempty"`
}
type InfraContractState string
const (
InfraContractStaged InfraContractState = "Staged"
InfraContractRequested InfraContractState = "Requested"
InfraContractReleased InfraContractState = "Released"
)
// +socialweb:lexicon=computer.socialweb.infra#contract
type InfraContract struct {
Name string `json:"name" apigen:"maxLength=63,pattern=^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$"`
State InfraContractState `json:"state,omitempty" apigen:"default=Staged,enum=Staged|Requested|Released"`
ReleaseRequestedAt string `json:"releaseRequestedAt,omitempty"`
ComputeContractTemplate `json:",inline"`
}
type InfraContractSecret struct {
Contract string `json:"contract"`
SecretsRef commonv1.SecretRef `json:"secretsRef"`
}
type InfraContractNode struct {
Contract string `json:"contract"`
OwnerDid string `json:"ownerDid,omitempty"`
Adopt bool `json:"adopt,omitempty"`
NodeJoin *ComputeContractNodeJoin `json:"nodeJoin,omitempty"`
NodeClaimRef commonv1.ObjectRef `json:"nodeClaimRef"`
}
type InfraRecordSync string
const (
InfraRecordSyncBoth InfraRecordSync = "Both"
InfraRecordSyncPublish InfraRecordSync = "Publish"
)
type InfraRecordBinding struct {
RepoRef commonv1.ObjectRef `json:"repoRef"`
Sync InfraRecordSync `json:"sync,omitempty" apigen:"default=Both,enum=Both|Publish"`
URI string `json:"uri,omitempty" apigen:"userEndpoint"`
EventSourceRefs []commonv1.ObjectRef `json:"eventSourceRefs,omitempty"`
}
type EphemeralInfraEnd string
const (
EphemeralInfraEndComplete EphemeralInfraEnd = "Complete"
EphemeralInfraEndDeadline EphemeralInfraEnd = "Deadline"
EphemeralInfraEndDeleted EphemeralInfraEnd = "Deleted"
)
type EphemeralInfraSpec struct {
InfraSpec `json:",inline"`
TTLSeconds *int32 `json:"ttlSeconds,omitempty" apigen:"default=3600,minimum=60"`
EndWhen EphemeralInfraEnd `json:"endWhen,omitempty" apigen:"default=Complete,enum=Complete|Deadline"`
}
type InfraPhase string
const (
InfraPhasePending InfraPhase = "Pending"
InfraPhaseStaged InfraPhase = "Staged"
InfraPhaseDeploying InfraPhase = "Deploying"
InfraPhaseDeployed InfraPhase = "Deployed"
InfraPhaseReleasing InfraPhase = "Releasing"
InfraPhaseReleased InfraPhase = "Released"
InfraPhaseDegraded InfraPhase = "Degraded"
InfraPhaseEnding InfraPhase = "Ending"
InfraPhaseDeleting InfraPhase = "Deleting"
InfraPhaseEnded InfraPhase = "Ended"
)
type InfraContractPhase string
const (
InfraContractPhaseStaged InfraContractPhase = "Staged"
InfraContractPhaseRequesting InfraContractPhase = "Requesting"
InfraContractPhaseDeployed InfraContractPhase = "Deployed"
InfraContractPhaseReleasing InfraContractPhase = "Releasing"
InfraContractPhaseReleased InfraContractPhase = "Released"
InfraContractPhaseFailed InfraContractPhase = "Failed"
)
type InfraContractStatus struct {
Name string `json:"name"`
Phase InfraContractPhase `json:"phase"`
ComputeContract string `json:"computeContract,omitempty"`
Winner string `json:"winner,omitempty"`
ReceiptURI string `json:"receiptUri,omitempty"`
Message string `json:"message,omitempty"`
}
type InfraSyncDirection string
const (
InfraSyncCreated InfraSyncDirection = "Created"
InfraSyncPushed InfraSyncDirection = "Pushed"
InfraSyncPulled InfraSyncDirection = "Pulled"
InfraSyncInSync InfraSyncDirection = "InSync"
InfraSyncRetained InfraSyncDirection = "Retained"
)
type InfraRecordStatus struct {
URI string `json:"uri,omitempty"`
CID string `json:"cid,omitempty"`
DeclarationHash string `json:"declarationHash,omitempty"`
SyncedGeneration int64 `json:"syncedGeneration,omitempty"`
SyncedAt string `json:"syncedAt,omitempty"`
Direction InfraSyncDirection `json:"direction,omitempty"`
}
type InfraStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Phase InfraPhase `json:"phase,omitempty"`
Message string `json:"message,omitempty"`
Contracts []InfraContractStatus `json:"contracts,omitempty"`
Record *InfraRecordStatus `json:"record,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}
type EphemeralInfraStatus struct {
InfraStatus `json:",inline"`
ExpiresAt string `json:"expiresAt,omitempty"`
EndedAt string `json:"endedAt,omitempty"`
EndReason EphemeralInfraEnd `json:"endReason,omitempty"`
}
const (
FinalizerInfra = "infra.socialweb.computer/release"
InfraKindLabel = "infra.socialweb.computer/kind"
InfraNameLabel = "infra.socialweb.computer/name"
InfraContractLabel = "infra.socialweb.computer/contract"
InfraCollectionLabel = "infra.socialweb.computer/collection"
InfraClusterLabel = "infra.socialweb.computer/cluster"
InfraIndexLabel = "infra.socialweb.computer/index"
InfraConditionSynced = "Synced"
InfraConditionSyncConflict = "SyncConflict"
InfraConditionRecordValid = "RecordValid"
InfraConditionRecordUnresolved = "RecordUnresolved"
InfraConditionRecordOrphaned = "RecordOrphaned"
InfraConditionRecordEnded = "RecordEnded"
InfraConditionRecordReserved = "RecordReserved"
InfraConditionIndexed = "Indexed"
InfraReasonRecordReadRetrying = "RecordReadRetrying"
InfraMessageRecordReadRetrying = "retrying: the PDS could not be reached"
)