-
Notifications
You must be signed in to change notification settings - Fork 5
/
model.go
244 lines (228 loc) · 9.3 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
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
// Copyright (c) 2022, Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
package types
import (
"time"
)
// ConnectionData object used to communicate with Object Store
type ConnectionData struct {
Secret ObjectStoreSecret `json:"secret"`
Endpoint string `json:"endpoint"`
RegionName string `json:"region_name"`
BucketName string `json:"bucket_name"`
BackupName string `json:"backup_name"`
VeleroTimeout string `json:"velero_timeout"`
}
// ObjectStoreSecret to render secret details
type ObjectStoreSecret struct {
SecretName string `json:"secret_name"`
SecretKey string `json:"secret_key"`
ObjectAccessKey string `json:"object_store_access_key"`
ObjectSecretKey string `json:"object_store_secret_key"`
}
// VeleroBackupStorageLocation defines the spec for BSL
type VeleroBackupStorageLocation struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata struct {
Annotations struct {
KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"`
} `json:"annotations"`
CreationTimestamp time.Time `json:"creationTimestamp"`
Generation int `json:"generation"`
Name string `json:"name"`
Namespace string `json:"namespace"`
ResourceVersion string `json:"resourceVersion"`
UID string `json:"uid"`
} `json:"metadata"`
Spec struct {
BackupSyncPeriod string `json:"backupSyncPeriod"`
Config struct {
Region string `json:"region"`
S3ForcePathStyle string `json:"s3ForcePathStyle"`
S3URL string `json:"s3Url"`
} `json:"config"`
Credential struct {
Key string `json:"key"`
Name string `json:"name"`
} `json:"credential"`
ObjectStorage struct {
Bucket string `json:"bucket"`
Prefix string `json:"prefix"`
} `json:"objectStorage"`
Provider string `json:"provider"`
} `json:"spec"`
Status struct {
LastSyncedTime time.Time `json:"lastSyncedTime"`
LastValidationTime time.Time `json:"lastValidationTime"`
Phase string `json:"phase"`
} `json:"status"`
}
// VeleroBackup defines the spec for backup
type VeleroBackup struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata struct {
Annotations struct {
KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"`
VeleroIoSourceClusterK8SGitversion string `json:"velero.io/source-cluster-k8s-gitversion"`
VeleroIoSourceClusterK8SMajorVersion string `json:"velero.io/source-cluster-k8s-major-version"`
VeleroIoSourceClusterK8SMinorVersion string `json:"velero.io/source-cluster-k8s-minor-version"`
} `json:"annotations"`
CreationTimestamp time.Time `json:"creationTimestamp"`
Generation int `json:"generation"`
Labels struct {
VeleroIoStorageLocation string `json:"velero.io/storage-location"`
} `json:"labels"`
Name string `json:"name"`
Namespace string `json:"namespace"`
ResourceVersion string `json:"resourceVersion"`
UID string `json:"uid"`
} `json:"metadata"`
Spec struct {
DefaultVolumesToRestic bool `json:"defaultVolumesToRestic"`
Hooks struct {
Resources []struct {
IncludedNamespaces []string `json:"includedNamespaces"`
LabelSelector struct {
MatchLabels struct {
App string `json:"app"`
} `json:"matchLabels"`
} `json:"labelSelector"`
Name string `json:"name"`
Post []struct {
Exec struct {
Command []string `json:"command"`
Container string `json:"container"`
OnError string `json:"onError"`
Timeout string `json:"timeout"`
} `json:"exec"`
} `json:"post"`
} `json:"resources"`
} `json:"hooks"`
IncludedNamespaces []string `json:"includedNamespaces"`
StorageLocation string `json:"storageLocation"`
TTL string `json:"ttl"`
} `json:"spec"`
Status struct {
CompletionTimestamp time.Time `json:"completionTimestamp"`
Expiration time.Time `json:"expiration"`
FormatVersion string `json:"formatVersion"`
Phase string `json:"phase"`
Progress struct {
ItemsBackedUp int `json:"itemsBackedUp"`
TotalItems int `json:"totalItems"`
} `json:"progress"`
StartTimestamp time.Time `json:"startTimestamp"`
Version int `json:"version"`
} `json:"status"`
}
// OpenSearchHealthResponse used to determine health details
type OpenSearchHealthResponse struct {
ClusterName string `json:"cluster_name"`
Status string `json:"status"`
TimedOut bool `json:"timed_out"`
NumberOfNodes int `json:"number_of_nodes"`
NumberOfDataNodes int `json:"number_of_data_nodes"`
DiscoveredMaster bool `json:"discovered_master"`
ActivePrimaryShards int `json:"active_primary_shards"`
ActiveShards int `json:"active_shards"`
RelocatingShards int `json:"relocating_shards"`
InitializingShards int `json:"initializing_shards"`
UnassignedShards int `json:"unassigned_shards"`
DelayedUnassignedShards int `json:"delayed_unassigned_shards"`
NumberOfPendingTasks int `json:"number_of_pending_tasks"`
NumberOfInFlightFetch int `json:"number_of_in_flight_fetch"`
TaskMaxWaitingInQueueMillis int `json:"task_max_waiting_in_queue_millis"`
ActiveShardsPercentAsNumber float64 `json:"active_shards_percent_as_number"`
}
// OpenSearchSnapshotRequestPayload struct for registering a snapshot
type OpenSearchSnapshotRequestPayload struct {
Type string `json:"type"`
Settings struct {
Client string `json:"client"`
Bucket string `json:"bucket"`
Region string `json:"region"`
Endpoint string `json:"endpoint"`
PathStyleAccess bool `json:"path_style_access"`
} `json:"settings"`
}
// OpenSearchOperationResponse to render common operational responses
type OpenSearchOperationResponse struct {
Acknowledged bool `json:"acknowledged,omitempty"`
}
// OpenSearchSnapshotResponse to render snapshot response
type OpenSearchSnapshotResponse struct {
Accepted bool `json:"accepted,omitempty"`
}
// OpenSearchSnapshotStatus to render all snapshot status
type OpenSearchSnapshotStatus struct {
Snapshots []Snapshot `json:"snapshots"`
}
// Snapshot to render snapshot status
type Snapshot struct {
Snapshot string `json:"snapshot"`
UUID string `json:"uuid"`
VersionID int `json:"version_id"`
Version string `json:"version"`
Indices []string `json:"indices"`
DataStreams []string `json:"data_streams"`
IncludeGlobalState bool `json:"include_global_state"`
State string `json:"state"`
StartTime time.Time `json:"start_time"`
StartTimeInMillis int64 `json:"start_time_in_millis"`
EndTime time.Time `json:"end_time"`
EndTimeInMillis int64 `json:"end_time_in_millis"`
DurationInMillis int `json:"duration_in_millis"`
Failures []interface{} `json:"failures"`
Shards struct {
Total int `json:"total"`
Failed int `json:"failed"`
Successful int `json:"successful"`
} `json:"shards"`
}
// OpenSearchDataStreams struct to render array of data streams info
type OpenSearchDataStreams struct {
DataStreams []DataStreams `json:"data_streams"`
}
// DataStreams struct to render data streams info
type DataStreams struct {
Name string `json:"name"`
TimestampField struct {
Name string `json:"name"`
} `json:"timestamp_field"`
Indices []struct {
IndexName string `json:"index_name"`
IndexUUID string `json:"index_uuid"`
} `json:"indices"`
Generation int `json:"generation"`
Status string `json:"status"`
Template string `json:"template"`
}
// OpenSearchClusterInfo renders opensearch cluster reachability
type OpenSearchClusterInfo struct {
Name string `json:"name"`
ClusterName string `json:"cluster_name"`
ClusterUUID string `json:"cluster_uuid"`
Version struct {
Distribution string `json:"distribution"`
Number string `json:"number"`
BuildType string `json:"build_type"`
BuildHash string `json:"build_hash"`
BuildDate time.Time `json:"build_date"`
BuildSnapshot bool `json:"build_snapshot"`
LuceneVersion string `json:"lucene_version"`
MinimumWireCompatibilityVersion string `json:"minimum_wire_compatibility_version"`
MinimumIndexCompatibilityVersion string `json:"minimum_index_compatibility_version"`
} `json:"version"`
Tagline string `json:"tagline"`
}
// OpenSearchSecureSettingsReloadStatus renders status of nodes on reload secure settings
type OpenSearchSecureSettingsReloadStatus struct {
ClusterNodes struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
} `json:"_nodes"`
ClusterName string `json:"cluster_name"`
}