-
Notifications
You must be signed in to change notification settings - Fork 8
/
types.go
413 lines (341 loc) · 15.8 KB
/
types.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package api
import (
"fmt"
"time"
"google.golang.org/protobuf/types/known/timestamppb"
)
type CreateKubernetesClusterRequest struct {
Ephemeral bool `json:"ephemeral,omitempty"`
DocumentedPurpose string `json:"documented_purpose,omitempty"`
AuthorizedSshKeys []string `json:"authorized_ssh_keys,omitempty"`
MachineType string `json:"machine_type,omitempty"`
Feature []string `json:"feature,omitempty"`
Interactive bool `json:"interactive,omitempty"`
Label []*LabelEntry `json:"label,omitempty"`
UniqueTag string `json:"unique_tag,omitempty"`
InternalExtra string `json:"internal_extra,omitempty"`
Deadline *timestamppb.Timestamp `json:"deadline,omitempty"`
Experimental any `json:"experimental,omitempty"`
}
type GetKubernetesClusterRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
}
type EnsureKubernetesClusterRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
}
type WaitKubernetesClusterRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
}
type CreateKubernetesClusterResponse struct {
Status string `json:"status,omitempty"`
ClusterId string `json:"cluster_id,omitempty"`
Cluster *KubernetesCluster `json:"cluster,omitempty"`
Registry *ImageRegistry `json:"registry,omitempty"`
BuildCluster *BuildCluster `json:"build_cluster,omitempty"`
Deadline string `json:"deadline,omitempty"`
}
type GetKubernetesClusterResponse struct {
Cluster *KubernetesCluster `json:"cluster,omitempty"`
Registry *ImageRegistry `json:"registry,omitempty"`
BuildCluster *BuildCluster `json:"build_cluster,omitempty"`
Deadline string `json:"deadline,omitempty"`
}
type StartCreateKubernetesClusterResponse struct {
ClusterId string `json:"cluster_id,omitempty"`
ClusterFragment *KubernetesCluster `json:"cluster_fragment,omitempty"`
Registry *ImageRegistry `json:"registry,omitempty"`
Deadline string `json:"deadline,omitempty"`
}
type CreateContainersRequest struct {
MachineType string `json:"machine_type,omitempty"`
Container []*ContainerRequest `json:"container,omitempty"`
Compose []*ComposeRequest `json:"compose,omitempty"`
Interactive bool `json:"interactive,omitempty"`
DevelopmentMode bool `json:"development_mode,omitempty"`
Feature []string `json:"feature,omitempty"`
Label []*LabelEntry `json:"label,omitempty"`
InternalExtra string `json:"internal_extra,omitempty"`
Deadline *timestamppb.Timestamp `json:"deadline,omitempty"`
}
type StartContainersRequest struct {
Id string `json:"id,omitempty"`
Container []*ContainerRequest `json:"container,omitempty"`
}
type ContainerRequest struct {
Name string `json:"name,omitempty"`
Image string `json:"image,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Flag []string `json:"flag,omitempty"`
ExportPort []*ContainerPort `json:"export_port,omitempty"`
DockerSockPath string `json:"docker_sock_path,omitempty"`
NscStatePath string `json:"nsc_state_path,omitempty"`
}
type ComposeRequest struct {
Contents []byte `json:"contents,omitempty"`
}
type ContainerPort struct {
Proto string `json:"proto,omitempty"`
Port int32 `json:"port,omitempty"`
HttpMatchRule []*ContainerPort_HttpMatchRule `json:"http_match_rule,omitempty"`
}
type ContainerPort_HttpMatchRule struct {
Match *ContainerPort_HttpMatch `json:"match,omitempty"`
DoesNotRequireAuth bool `json:"does_not_require_auth,omitempty"`
}
type ContainerPort_HttpMatch struct {
Method []string `json:"method,omitempty"` // If empty, matches any method.
Path string `json:"path,omitempty"` // If empty, matches any path.
}
type CreateContainersResponse struct {
ClusterId string `json:"cluster_id,omitempty"`
ClusterUrl string `json:"cluster_url,omitempty"`
Container []*Container `json:"container,omitempty"`
}
type StartContainersResponse struct {
Container []*Container `json:"container,omitempty"`
}
type Container struct {
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ExportedPort []*Container_ExportedContainerPort `json:"exported_port,omitempty"`
}
type Container_ExportedContainerPort struct {
Proto string `json:"proto,omitempty"`
ContainerPort int32 `json:"container_port,omitempty"`
ExportedPort int32 `json:"exported_port,omitempty"` // Port exposed within the guest.
IngressFqdn string `json:"ingress_fqdn,omitempty"`
HttpMatchRule []*ContainerPort_HttpMatchRule `json:"http_match_rule,omitempty"`
}
type ListKubernetesClustersRequest struct {
IncludePreviousRuns bool `json:"include_previous_runs,omitempty"`
PaginationCursor []byte `json:"pagination_cursor,omitempty"`
MaxEntries int64 `json:"max_entries,omitempty"`
NotOlderThan *time.Time `json:"not_older_than,omitempty"`
LabelFilter []*LabelFilterEntry `json:"label_filter,omitempty"`
}
type LabelFilterEntry struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Op string `json:"op,omitempty"`
}
type ListKubernetesClustersResponse struct {
Clusters []KubernetesClusterMetadata `json:"cluster"`
}
type KubernetesClusterMetadata struct {
ClusterId string `json:"cluster_id,omitempty"`
Created string `json:"created,omitempty"`
DestroyedAt string `json:"destroyed_at,omitempty"`
Deadline string `json:"deadline,omitempty"`
DocumentedPurpose string `json:"documented_purpose,omitempty"`
Shape *ClusterShape `json:"shape,omitempty"`
KubernetesDistribution string `json:"kubernetes_distribution,omitempty"`
Platform []string `json:"platform,omitempty"`
IngressDomain string `json:"ingress_domain,omitempty"`
Label []*LabelEntry `json:"label,omitempty"`
CreatorId string `json:"creator_id,omitempty"`
GithubWorkflow *GithubWorkflowInfo `json:"github_workflow,omitempty"`
}
type KubernetesCluster struct {
AppURL string `json:"app_url,omitempty"`
ClusterId string `json:"cluster_id,omitempty"`
Created string `json:"created,omitempty"`
DestroyedAt string `json:"destroyed_at,omitempty"`
Deadline string `json:"deadline,omitempty"`
SSHProxyEndpoint string `json:"ssh_proxy_endpoint,omitempty"`
SshPrivateKey []byte `json:"ssh_private_key,omitempty"`
DocumentedPurpose string `json:"documented_purpose,omitempty"`
Shape *ClusterShape `json:"shape,omitempty"`
EndpointAddress string `json:"endpoint_address,omitempty"`
CertificateAuthorityData []byte `json:"certificate_authority_data,omitempty"`
ClientCertificateData []byte `json:"client_certificate_data,omitempty"`
ClientKeyData []byte `json:"client_key_data,omitempty"`
KubernetesDistribution string `json:"kubernetes_distribution,omitempty"`
Platform []string `json:"platform,omitempty"`
IngressDomain string `json:"ingress_domain,omitempty"`
Label []*LabelEntry `json:"label,omitempty"`
CreatorId string `json:"creator_id,omitempty"`
GithubWorkflow *GithubWorkflowInfo `json:"github_workflow,omitempty"`
ServiceState []*Cluster_ServiceState `json:"service_state,omitempty"`
TlsBackedPort []*KubernetesCluster_TlsBackedPort `json:"tls_backed_port,omitempty"`
}
type Cluster_ServiceState struct {
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
Endpoint string `json:"endpoint,omitempty"` // Service-specific endpoint.
Public bool `json:"public,omitempty"`
}
type KubernetesCluster_TlsBackedPort struct {
Name string `json:"name,omitempty"`
Port int32 `json:"port,omitempty"`
ServerName string `json:"server_name,omitempty"`
}
type GithubWorkflowInfo struct {
Repository string `json:"repository,omitempty"`
RunId string `json:"run_id,omitempty"`
RunAttempt string `json:"run_attempt,omitempty"`
Sha string `json:"sha,omitempty"`
Ref string `json:"ref,omitempty"`
Actor string `json:"actor,omitempty"`
Workflow string `json:"workflow,omitempty"`
}
type GetImageRegistryResponse struct {
Registry *ImageRegistry `json:"registry,omitempty"`
NSCR *ImageRegistry `json:"nscr,omitempty"`
}
type TailLogsRequest struct {
ClusterID string `json:"cluster_id,omitempty"`
UseBlockLabels bool `json:"use_block_labels,omitempty"`
Include []*LogsSelector `json:"include,omitempty"`
Exclude []*LogsSelector `json:"exclude,omitempty"`
}
type GetLogsRequest struct {
ClusterID string `json:"cluster_id,omitempty"`
UseBlockLabels bool `json:"use_block_labels,omitempty"`
StartTs *time.Time `json:"start_ts,omitempty"`
EndTs *time.Time `json:"end_ts,omitempty"`
Include []*LogsSelector `json:"include,omitempty"`
Exclude []*LogsSelector `json:"exclude,omitempty"`
}
type GetLogsResponse struct {
LogBlock []LogBlock `json:"log_block,omitempty"`
}
type LogsSelector struct {
Source string `json:"source,omitempty"`
Namespace string `json:"namespace,omitempty"`
PodName string `json:"pod_name,omitempty"`
ContainerName string `json:"container_name,omitempty"`
ContainerID string `json:"container_id,omitempty"`
}
type LogBlock struct {
Line []LogLine `json:"line,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
type LogLine struct {
Timestamp time.Time `json:"timestamp,omitempty"`
Content string `json:"content,omitempty"`
Stream string `json:"stream,omitempty"`
}
func (l LogLine) String() string {
return fmt.Sprintf("%s stream=%s msg=%s", l.Timestamp.Format(time.RFC3339), l.Stream, l.Content)
}
type ImageRegistry struct {
EndpointAddress string `json:"endpoint_address,omitempty"`
Repository string `json:"repository,omitempty"`
}
type ClusterShape struct {
VirtualCpu int32 `json:"virtual_cpu,omitempty"`
MemoryMegabytes int32 `json:"memory_megabytes,omitempty"`
MachineArch string `json:"machine_arch,omitempty"`
}
type DestroyKubernetesClusterRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
}
type SuspendKubernetesClusterRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
}
type ReleaseKubernetesClusterRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
}
type WakeKubernetesClusterRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
}
type LabelEntry struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
}
type BuildCluster struct {
Colocated *BuildCluster_ColocatedPort `json:"colocated,omitempty"`
Resumable bool `json:"resumable,omitempty"`
DoesNotRequireRefresh bool `json:"does_not_require_refresh,omitempty"`
}
type BuildCluster_ColocatedPort struct {
TargetPort int32 `json:"target_port,omitempty"`
ClusterId string `json:"cluster_id,omitempty"`
}
type Attachment struct {
TypeURL string `json:"type_url,omitempty"`
Content []byte `json:"content,omitempty"`
}
type RefreshKubernetesClusterRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
ExtendBySecs int32 `json:"extend_by_secs,omitempty"`
EnsureMinimumSecs int32 `json:"ensure_minimum_secs,omitempty"`
}
type RefreshKubernetesClusterResponse struct {
NewDeadline string `json:"new_deadline,omitempty"`
}
type GetKubernetesClusterSummaryRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
Resource []string `json:"resource,omitempty"`
}
type GetKubernetesClusterSummaryResponse struct {
Summary []ResourceSummary `json:"summary,omitempty"`
}
type ResourceSummary struct {
Resource string `json:"resource,omitempty"`
PerResource map[string]Resource `json:"per_resource,omitempty"`
GenVersion int32 `json:"gen_version,omitempty"`
}
type Resource struct {
Namespace string `json:"namespace,omitempty"`
Name string `json:"name,omitempty"`
Uid string `json:"uid,omitempty"` // Union value - depends on resource type.
Parent []*ResourceSummary_Resource_Ref `json:"parent,omitempty"`
CreationTime *time.Time `json:"creation_time,omitempty"`
UpdatedTime *time.Time `json:"updated_time,omitempty"`
Tombstone *time.Time `json:"tombstone,omitempty"` // If set, the resource has been removed.
// For pods.
Container []*ResourceSummary_Resource_Container `json:"container,omitempty"`
Phase string `json:"phase,omitempty"`
// For apps.
ReplicaCount string `json:"replica_count,omitempty"`
ReplicaUpdated string `json:"replica_updated,omitempty"`
ReplicaReady string `json:"replica_ready,omitempty"`
ReplicaAvailable string `json:"replica_available,omitempty"`
ObservedGeneration string `json:"observed_generation,omitempty"`
// For ingress.
HttpMatchRule []*ContainerPort_HttpMatchRule `json:"http_match_rule,omitempty"`
TargetExportedPort int32 `json:"target_exported_port,omitempty"`
}
type ResourceSummary_Resource_Container struct {
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
TerminatedAt *time.Time `json:"terminated_at,omitempty"`
Ready bool `json:"ready,omitempty"`
RestartCount int64 `json:"restart_count,omitempty"`
Status string `json:"status,omitempty"`
NotRunningReason string `json:"not_running_reason,omitempty"`
ExportedPort []*Container_ExportedContainerPort `json:"exported_port,omitempty"`
}
type ResourceSummary_Resource_Ref struct {
Resource string `json:"resource,omitempty"`
Name string `json:"name,omitempty"`
Uid string `json:"uid,omitempty"`
}
type GetKubernetesConfigRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
}
type GetKubernetesConfigResponse struct {
Kubeconfig string `json:"kubeconfig,omitempty"`
}
type GetProfileResponse struct {
ClusterPlatform []string `json:"cluster_platform,omitempty"`
}
type RegisterIngressRequest struct {
ClusterId string `json:"cluster_id,omitempty"`
Name string `json:"name,omitempty"`
BackendEndpoint *IngressBackendEndpoint `json:"backend_endpoint,omitempty"`
HttpMatchRule []*ContainerPort_HttpMatchRule `json:"http_match_rule,omitempty"`
}
type IngressBackendEndpoint struct {
IpAddr string `json:"ip_addr,omitempty"`
Port int32 `json:"port,omitempty"`
}
type RegisterIngressResponse struct {
Fqdn string `json:"fqdn,omitempty"`
}