-
Notifications
You must be signed in to change notification settings - Fork 138
/
model.go
2296 lines (1999 loc) · 77.7 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
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package api
import (
"fmt"
"strconv"
"time"
"github.com/sirupsen/logrus"
"github.com/rancher/go-rancher/api"
"github.com/rancher/go-rancher/client"
corev1 "k8s.io/api/core/v1"
"github.com/longhorn/longhorn-manager/controller"
"github.com/longhorn/longhorn-manager/datastore"
"github.com/longhorn/longhorn-manager/engineapi"
"github.com/longhorn/longhorn-manager/manager"
"github.com/longhorn/longhorn-manager/types"
"github.com/longhorn/longhorn-manager/util"
longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
)
type Empty struct {
client.Resource
}
type Volume struct {
client.Resource
Name string `json:"name"`
Size string `json:"size"`
Frontend longhorn.VolumeFrontend `json:"frontend"`
DisableFrontend bool `json:"disableFrontend"`
FromBackup string `json:"fromBackup"`
RestoreVolumeRecurringJob longhorn.RestoreVolumeRecurringJobType `json:"restoreVolumeRecurringJob"`
DataSource longhorn.VolumeDataSource `json:"dataSource"`
DataLocality longhorn.DataLocality `json:"dataLocality"`
StaleReplicaTimeout int `json:"staleReplicaTimeout"`
State longhorn.VolumeState `json:"state"`
Robustness longhorn.VolumeRobustness `json:"robustness"`
Image string `json:"image"`
CurrentImage string `json:"currentImage"`
BackingImage string `json:"backingImage"`
Created string `json:"created"`
LastBackup string `json:"lastBackup"`
LastBackupAt string `json:"lastBackupAt"`
LastAttachedBy string `json:"lastAttachedBy"`
Standby bool `json:"standby"`
RestoreRequired bool `json:"restoreRequired"`
RestoreInitiated bool `json:"restoreInitiated"`
RevisionCounterDisabled bool `json:"revisionCounterDisabled"`
SnapshotDataIntegrity longhorn.SnapshotDataIntegrity `json:"snapshotDataIntegrity"`
UnmapMarkSnapChainRemoved longhorn.UnmapMarkSnapChainRemoved `json:"unmapMarkSnapChainRemoved"`
BackupCompressionMethod longhorn.BackupCompressionMethod `json:"backupCompressionMethod"`
ReplicaSoftAntiAffinity longhorn.ReplicaSoftAntiAffinity `json:"replicaSoftAntiAffinity"`
ReplicaZoneSoftAntiAffinity longhorn.ReplicaZoneSoftAntiAffinity `json:"replicaZoneSoftAntiAffinity"`
ReplicaDiskSoftAntiAffinity longhorn.ReplicaDiskSoftAntiAffinity `json:"replicaDiskSoftAntiAffinity"`
DataEngine longhorn.DataEngineType `json:"dataEngine"`
OfflineReplicaRebuilding longhorn.OfflineReplicaRebuilding `json:"offlineReplicaRebuilding"`
OfflineReplicaRebuildingRequired bool `json:"offlineReplicaRebuildingRequired"`
SnapshotMaxCount int `json:"snapshotMaxCount"`
SnapshotMaxSize string `json:"snapshotMaxSize"`
FreezeFilesystemForSnapshot longhorn.FreezeFilesystemForSnapshot `json:"freezeFilesystemForSnapshot"`
DiskSelector []string `json:"diskSelector"`
NodeSelector []string `json:"nodeSelector"`
RecurringJobSelector []longhorn.VolumeRecurringJob `json:"recurringJobSelector"`
NumberOfReplicas int `json:"numberOfReplicas"`
ReplicaAutoBalance longhorn.ReplicaAutoBalance `json:"replicaAutoBalance"`
Conditions map[string]longhorn.Condition `json:"conditions"`
KubernetesStatus longhorn.KubernetesStatus `json:"kubernetesStatus"`
CloneStatus longhorn.VolumeCloneStatus `json:"cloneStatus"`
Ready bool `json:"ready"`
AccessMode longhorn.AccessMode `json:"accessMode"`
ShareEndpoint string `json:"shareEndpoint"`
ShareState longhorn.ShareManagerState `json:"shareState"`
Migratable bool `json:"migratable"`
Encrypted bool `json:"encrypted"`
Replicas []Replica `json:"replicas"`
Controllers []Controller `json:"controllers"`
BackupStatus []BackupStatus `json:"backupStatus"`
RestoreStatus []RestoreStatus `json:"restoreStatus"`
PurgeStatus []PurgeStatus `json:"purgeStatus"`
RebuildStatus []RebuildStatus `json:"rebuildStatus"`
VolumeAttachment VolumeAttachment `json:"volumeAttachment"`
}
// Snapshot struct is used for the snapshot* actions
type Snapshot struct {
client.Resource
longhorn.SnapshotInfo
Checksum string `json:"checksum"`
}
// SnapshotCR struct is used for the snapshotCR* actions
type SnapshotCR struct {
client.Resource
Name string `json:"name"`
CRCreationTime string `json:"crCreationTime"`
Volume string `json:"volume"`
CreateSnapshot bool `json:"createSnapshot"`
Parent string `json:"parent"`
Children map[string]bool `json:"children"`
MarkRemoved bool `json:"markRemoved"`
UserCreated bool `json:"userCreated"`
CreationTime string `json:"creationTime"`
Size int64 `json:"size"`
Labels map[string]string `json:"labels"`
OwnerID string `json:"ownerID"`
Error string `json:"error,omitempty"`
RestoreSize int64 `json:"restoreSize"`
ReadyToUse bool `json:"readyToUse"`
Checksum string `json:"checksum"`
}
type BackupTarget struct {
client.Resource
engineapi.BackupTarget
}
type BackupVolume struct {
client.Resource
Name string `json:"name"`
Size string `json:"size"`
Labels map[string]string `json:"labels"`
Created string `json:"created"`
LastBackupName string `json:"lastBackupName"`
LastBackupAt string `json:"lastBackupAt"`
DataStored string `json:"dataStored"`
Messages map[string]string `json:"messages"`
BackingImageName string `json:"backingImageName"`
BackingImageChecksum string `json:"backingImageChecksum"`
StorageClassName string `json:"storageClassName"`
}
// SyncBackupResource is used for the Backup*Sync* actions
type SyncBackupResource struct {
SyncAllBackupTargets bool `json:"syncAllBackupTargets"`
SyncBackupTarget bool `json:"syncBackupTarget"`
SyncAllBackupVolumes bool `json:"syncAllBackupVolumes"`
SyncBackupVolume bool `json:"syncBackupVolume"`
}
type Backup struct {
client.Resource
Name string `json:"name"`
State longhorn.BackupState `json:"state"`
Progress int `json:"progress"`
Error string `json:"error"`
URL string `json:"url"`
SnapshotName string `json:"snapshotName"`
SnapshotCreated string `json:"snapshotCreated"`
Created string `json:"created"`
Size string `json:"size"`
Labels map[string]string `json:"labels"`
Messages map[string]string `json:"messages"`
VolumeName string `json:"volumeName"`
VolumeSize string `json:"volumeSize"`
VolumeCreated string `json:"volumeCreated"`
VolumeBackingImageName string `json:"volumeBackingImageName"`
CompressionMethod string `json:"compressionMethod"`
}
type BackupBackingImage struct {
client.Resource
Name string `json:"name"`
State longhorn.BackupState `json:"state"`
Progress int `json:"progress"`
Error string `json:"error"`
URL string `json:"url"`
Created string `json:"created"`
Size int64 `json:"size"`
Labels map[string]string `json:"labels"`
Messages map[string]string `json:"messages"`
CompressionMethod string `json:"compressionMethod"`
}
type Setting struct {
client.Resource
Applied bool `json:"applied"`
Name string `json:"name"`
Value string `json:"value"`
Definition types.SettingDefinition `json:"definition"`
}
type Instance struct {
Name string `json:"name"`
NodeID string `json:"hostId"`
Address string `json:"address"`
Running bool `json:"running"`
Image string `json:"image"`
CurrentImage string `json:"currentImage"`
InstanceManagerName string `json:"instanceManagerName"`
}
type Controller struct {
Instance
Size string `json:"size"`
ActualSize string `json:"actualSize"`
Endpoint string `json:"endpoint"`
LastRestoredBackup string `json:"lastRestoredBackup"`
RequestedBackupRestore string `json:"requestedBackupRestore"`
IsExpanding bool `json:"isExpanding"`
LastExpansionError string `json:"lastExpansionError"`
LastExpansionFailedAt string `json:"lastExpansionFailedAt"`
UnmapMarkSnapChainRemovedEnabled bool `json:"unmapMarkSnapChainRemovedEnabled"`
}
type Replica struct {
Instance
DiskID string `json:"diskID"`
DiskPath string `json:"diskPath"`
DataPath string `json:"dataPath"`
Mode string `json:"mode"`
FailedAt string `json:"failedAt"`
DataEngine string `json:"dataEngine"`
}
type Attachment struct {
AttachmentID string `json:"attachmentID"`
AttachmentType string `json:"attachmentType"`
NodeID string `json:"nodeID"`
Parameters map[string]string `json:"parameters"`
// Indicate whether this attachment ticket has been satisfied
Satisfied bool `json:"satisfied"`
Conditions []longhorn.Condition `json:"conditions"`
}
type VolumeAttachment struct {
Attachments map[string]Attachment `json:"attachments"`
Volume string `json:"volume"`
}
type EngineImage struct {
client.Resource
Name string `json:"name"`
Image string `json:"image"`
Default bool `json:"default"`
longhorn.EngineImageStatus
}
type BackingImage struct {
client.Resource
Name string `json:"name"`
UUID string `json:"uuid"`
SourceType string `json:"sourceType"`
Parameters map[string]string `json:"parameters"`
ExpectedChecksum string `json:"expectedChecksum"`
DiskFileStatusMap map[string]longhorn.BackingImageDiskFileStatus `json:"diskFileStatusMap"`
Size int64 `json:"size"`
CurrentChecksum string `json:"currentChecksum"`
DeletionTimestamp string `json:"deletionTimestamp"`
}
type BackingImageCleanupInput struct {
Disks []string `json:"disks"`
}
type AttachInput struct {
HostID string `json:"hostId"`
DisableFrontend bool `json:"disableFrontend"`
AttachedBy string `json:"attachedBy"`
AttacherType string `json:"attacherType"`
AttachmentID string `json:"attachmentID"`
}
type DetachInput struct {
AttachmentID string `json:"attachmentID"`
HostID string `json:"hostId"`
ForceDetach bool `json:"forceDetach"`
}
type SnapshotInput struct {
Name string `json:"name"`
Labels map[string]string `json:"labels"`
}
type SnapshotCRInput struct {
Name string `json:"name"`
Labels map[string]string `json:"labels"`
}
type BackupInput struct {
Name string `json:"name"`
}
type ReplicaRemoveInput struct {
Name string `json:"name"`
}
type SalvageInput struct {
Names []string `json:"names"`
}
type EngineUpgradeInput struct {
Image string `json:"image"`
}
type UpdateReplicaCountInput struct {
ReplicaCount int `json:"replicaCount"`
}
type UpdateReplicaAutoBalanceInput struct {
ReplicaAutoBalance string `json:"replicaAutoBalance"`
}
type UpdateDataLocalityInput struct {
DataLocality string `json:"dataLocality"`
}
type UpdateAccessModeInput struct {
AccessMode string `json:"accessMode"`
}
type UpdateSnapshotDataIntegrityInput struct {
SnapshotDataIntegrity string `json:"snapshotDataIntegrity"`
}
type UpdateSnapshotMaxCountInput struct {
SnapshotMaxCount int `json:"snapshotMaxCount"`
}
type UpdateSnapshotMaxSizeInput struct {
SnapshotMaxSize string `json:"snapshotMaxSize"`
}
type UpdateOfflineReplicaRebuildingInput struct {
OfflineReplicaRebuilding string `json:"offlineReplicaRebuilding"`
}
type UpdateBackupCompressionMethodInput struct {
BackupCompressionMethod string `json:"backupCompressionMethod"`
}
type UpdateUnmapMarkSnapChainRemovedInput struct {
UnmapMarkSnapChainRemoved string `json:"unmapMarkSnapChainRemoved"`
}
type UpdateReplicaSoftAntiAffinityInput struct {
ReplicaSoftAntiAffinity string `json:"replicaSoftAntiAffinity"`
}
type UpdateReplicaZoneSoftAntiAffinityInput struct {
ReplicaZoneSoftAntiAffinity string `json:"replicaZoneSoftAntiAffinity"`
}
type UpdateReplicaDiskSoftAntiAffinityInput struct {
ReplicaDiskSoftAntiAffinity string `json:"replicaDiskSoftAntiAffinity"`
}
type UpdateSnapshotMaxCount struct {
SnapshotMaxCount int `json:"snapshotMaxCount"`
}
type UpdateSnapshotMaxSize struct {
SnapshotMaxSize string `json:"snapshotMaxSize"`
}
type UpdateFreezeFilesystemForSnapshotInput struct {
FreezeFilesystemForSnapshot string `json:"freezeFilesystemForSnapshot"`
}
type PVCreateInput struct {
PVName string `json:"pvName"`
FSType string `json:"fsType"`
SecretName string `json:"secretName"`
SecretNamespace string `json:"secretNamespace"`
StorageClassName string `json:"storageClassName"`
}
type PVCCreateInput struct {
Namespace string `json:"namespace"`
PVCName string `json:"pvcName"`
}
type ActivateInput struct {
Frontend string `json:"frontend"`
}
type ExpandInput struct {
Size string `json:"size"`
}
type Node struct {
client.Resource
Name string `json:"name"`
Address string `json:"address"`
AllowScheduling bool `json:"allowScheduling"`
EvictionRequested bool `json:"evictionRequested"`
Disks map[string]DiskInfo `json:"disks"`
Conditions map[string]longhorn.Condition `json:"conditions"`
Tags []string `json:"tags"`
Region string `json:"region"`
Zone string `json:"zone"`
InstanceManagerCPURequest int `json:"instanceManagerCPURequest"`
AutoEvicting bool `json:"autoEvicting"`
}
type DiskStatus struct {
Conditions map[string]longhorn.Condition `json:"conditions"`
StorageAvailable int64 `json:"storageAvailable"`
StorageScheduled int64 `json:"storageScheduled"`
StorageMaximum int64 `json:"storageMaximum"`
ScheduledReplica map[string]int64 `json:"scheduledReplica"`
DiskUUID string `json:"diskUUID"`
}
type DiskInfo struct {
longhorn.DiskSpec
// To convert CR status.Conditions from datatype map to slice, replace longhorn.DiskStatus with DiskStatus to keep it use datatype map.
// Therefore, the UI (RESTful endpoint) does not need to do any changes.
DiskStatus
}
type DiskUpdateInput struct {
Disks map[string]longhorn.DiskSpec `json:"disks"`
}
type Event struct {
client.Resource
Event corev1.Event `json:"event"`
EventType string `json:"eventType"`
}
type SupportBundle struct {
client.Resource
NodeID string `json:"nodeID"`
State longhorn.SupportBundleState `json:"state"`
Name string `json:"name"`
ErrorMessage string `json:"errorMessage"`
ProgressPercentage int `json:"progressPercentage"`
}
type SupportBundleInitateInput struct {
IssueURL string `json:"issueURL"`
Description string `json:"description"`
}
type SystemBackup struct {
client.Resource
Name string `json:"name"`
VolumeBackupPolicy longhorn.SystemBackupCreateVolumeBackupPolicy `json:"volumeBackupPolicy"`
Version string `json:"version,omitempty"`
ManagerImage string `json:"managerImage,omitempty"`
State longhorn.SystemBackupState `json:"state,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Error string `json:"error,omitempty"`
}
type SystemBackupInput struct {
Name string `json:"name"`
VolumeBackupPolicy longhorn.SystemBackupCreateVolumeBackupPolicy `json:"volumeBackupPolicy"`
}
type SystemRestore struct {
client.Resource
Name string `json:"name"`
SystemBackup string `json:"systemBackup"`
State longhorn.SystemRestoreState `json:"state,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Error string `json:"error,omitempty"`
}
type SystemRestoreInput struct {
Name string `json:"name"`
SystemBackup string `json:"systemBackup"`
}
type Tag struct {
client.Resource
Name string `json:"name"`
TagType string `json:"tagType"`
}
type BackupStatus struct {
client.Resource
Name string `json:"id"`
Snapshot string `json:"snapshot"`
Progress int `json:"progress"`
BackupURL string `json:"backupURL"`
Error string `json:"error"`
State string `json:"state"`
Replica string `json:"replica"`
Size string `json:"size"`
}
type RestoreStatus struct {
client.Resource
Replica string `json:"replica"`
IsRestoring bool `json:"isRestoring"`
LastRestored string `json:"lastRestored"`
Progress int `json:"progress"`
Error string `json:"error"`
Filename string `json:"filename"`
State string `json:"state"`
BackupURL string `json:"backupURL"`
}
type PurgeStatus struct {
client.Resource
Error string `json:"error"`
IsPurging bool `json:"isPurging"`
Progress int `json:"progress"`
Replica string `json:"replica"`
State string `json:"state"`
}
type RebuildStatus struct {
client.Resource
Error string `json:"error"`
IsRebuilding bool `json:"isRebuilding"`
Progress int `json:"progress"`
Replica string `json:"replica"`
State string `json:"state"`
FromReplica string `json:"fromReplica"`
}
type InstanceManager struct {
client.Resource
CurrentState longhorn.InstanceManagerState `json:"currentState"`
Image string `json:"image"`
Name string `json:"name"`
NodeID string `json:"nodeID"`
ManagerType string `json:"managerType"`
DataEngine string `json:"dataEngine"`
InstanceEngines map[string]longhorn.InstanceProcess `json:"instanceEngines"`
InstanceReplicas map[string]longhorn.InstanceProcess `json:"instanceReplicas"`
Instances map[string]longhorn.InstanceProcess `json:"instances"`
}
type RecurringJob struct {
client.Resource
longhorn.RecurringJobSpec
}
type Orphan struct {
client.Resource
Name string `json:"name"`
longhorn.OrphanSpec
}
type VolumeRecurringJob struct {
client.Resource
longhorn.VolumeRecurringJob
}
type VolumeRecurringJobInput struct {
longhorn.VolumeRecurringJob
}
type BackupTargetListOutput struct {
Data []BackupTarget `json:"data"`
Type string `json:"type"`
}
type BackupVolumeListOutput struct {
Data []BackupVolume `json:"data"`
Type string `json:"type"`
}
type BackupListOutput struct {
Data []Backup `json:"data"`
Type string `json:"type"`
}
type SnapshotListOutput struct {
Data []Snapshot `json:"data"`
Type string `json:"type"`
}
type SnapshotCRListOutput struct {
Data []SnapshotCR `json:"data"`
Type string `json:"type"`
}
func NewSchema() *client.Schemas {
schemas := &client.Schemas{}
schemas.AddType("apiVersion", client.Resource{})
schemas.AddType("schema", client.Schema{})
schemas.AddType("error", client.ServerApiError{})
schemas.AddType("attachInput", AttachInput{})
schemas.AddType("detachInput", DetachInput{})
schemas.AddType("snapshotInput", SnapshotInput{})
schemas.AddType("snapshotCRInput", SnapshotCRInput{})
schemas.AddType("backup", Backup{})
schemas.AddType("backupInput", BackupInput{})
schemas.AddType("backupStatus", BackupStatus{})
schemas.AddType("syncBackupResource", SyncBackupResource{})
schemas.AddType("orphan", Orphan{})
schemas.AddType("restoreStatus", RestoreStatus{})
schemas.AddType("purgeStatus", PurgeStatus{})
schemas.AddType("rebuildStatus", RebuildStatus{})
schemas.AddType("replicaRemoveInput", ReplicaRemoveInput{})
schemas.AddType("salvageInput", SalvageInput{})
schemas.AddType("activateInput", ActivateInput{})
schemas.AddType("expandInput", ExpandInput{})
schemas.AddType("engineUpgradeInput", EngineUpgradeInput{})
schemas.AddType("replica", Replica{})
schemas.AddType("controller", Controller{})
schemas.AddType("diskUpdate", longhorn.DiskSpec{})
schemas.AddType("UpdateReplicaCountInput", UpdateReplicaCountInput{})
schemas.AddType("UpdateReplicaAutoBalanceInput", UpdateReplicaAutoBalanceInput{})
schemas.AddType("UpdateDataLocalityInput", UpdateDataLocalityInput{})
schemas.AddType("UpdateAccessModeInput", UpdateAccessModeInput{})
schemas.AddType("UpdateSnapshotDataIntegrityInput", UpdateSnapshotDataIntegrityInput{})
schemas.AddType("UpdateSnapshotMaxCountInput", UpdateSnapshotMaxCountInput{})
schemas.AddType("UpdateSnapshotMaxSizeInput", UpdateSnapshotMaxSizeInput{})
schemas.AddType("UpdateOfflineReplicaRebuildingInput", UpdateOfflineReplicaRebuildingInput{})
schemas.AddType("UpdateBackupCompressionInput", UpdateBackupCompressionMethodInput{})
schemas.AddType("UpdateUnmapMarkSnapChainRemovedInput", UpdateUnmapMarkSnapChainRemovedInput{})
schemas.AddType("UpdateReplicaSoftAntiAffinityInput", UpdateReplicaSoftAntiAffinityInput{})
schemas.AddType("UpdateReplicaZoneSoftAntiAffinityInput", UpdateReplicaZoneSoftAntiAffinityInput{})
schemas.AddType("UpdateReplicaDiskSoftAntiAffinityInput", UpdateReplicaDiskSoftAntiAffinityInput{})
schemas.AddType("UpdateFreezeFilesystemForSnapshotInput", UpdateFreezeFilesystemForSnapshotInput{})
schemas.AddType("workloadStatus", longhorn.WorkloadStatus{})
schemas.AddType("cloneStatus", longhorn.VolumeCloneStatus{})
schemas.AddType("empty", Empty{})
schemas.AddType("volumeRecurringJob", VolumeRecurringJob{})
schemas.AddType("volumeRecurringJobInput", VolumeRecurringJobInput{})
schemas.AddType("PVCreateInput", PVCreateInput{})
schemas.AddType("PVCCreateInput", PVCCreateInput{})
schemas.AddType("settingDefinition", types.SettingDefinition{})
// to avoid duplicate name with built-in type condition
schemas.AddType("volumeCondition", longhorn.Condition{})
schemas.AddType("nodeCondition", longhorn.Condition{})
schemas.AddType("diskCondition", longhorn.Condition{})
schemas.AddType("longhornCondition", longhorn.Condition{})
schemas.AddType("event", Event{})
schemas.AddType("supportBundle", SupportBundle{})
schemas.AddType("supportBundleInitateInput", SupportBundleInitateInput{})
schemas.AddType("tag", Tag{})
schemas.AddType("instanceManager", InstanceManager{})
schemas.AddType("instanceProcess", longhorn.InstanceProcess{})
schemas.AddType("backingImageDiskFileStatus", longhorn.BackingImageDiskFileStatus{})
schemas.AddType("backingImageCleanupInput", BackingImageCleanupInput{})
attachmentSchema(schemas.AddType("attachment", Attachment{}))
volumeAttachmentSchema(schemas.AddType("volumeAttachment", VolumeAttachment{}))
volumeSchema(schemas.AddType("volume", Volume{}))
snapshotSchema(schemas.AddType("snapshot", Snapshot{}))
snapshotCRSchema(schemas.AddType("snapshotCR", SnapshotCR{}))
backupTargetSchema(schemas.AddType("backupTarget", BackupTarget{}))
backupVolumeSchema(schemas.AddType("backupVolume", BackupVolume{}))
backupBackingImageSchema(schemas.AddType("backupBackingImage", BackupBackingImage{}))
settingSchema(schemas.AddType("setting", Setting{}))
recurringJobSchema(schemas.AddType("recurringJob", RecurringJob{}))
engineImageSchema(schemas.AddType("engineImage", EngineImage{}))
backingImageSchema(schemas.AddType("backingImage", BackingImage{}))
nodeSchema(schemas.AddType("node", Node{}))
diskSchema(schemas.AddType("diskUpdateInput", DiskUpdateInput{}))
diskInfoSchema(schemas.AddType("diskInfo", DiskInfo{}))
kubernetesStatusSchema(schemas.AddType("kubernetesStatus", longhorn.KubernetesStatus{}))
backupTargetListOutputSchema(schemas.AddType("backupTargetListOutput", BackupTargetListOutput{}))
backupVolumeListOutputSchema(schemas.AddType("backupVolumeListOutput", BackupVolumeListOutput{}))
backupListOutputSchema(schemas.AddType("backupListOutput", BackupListOutput{}))
snapshotListOutputSchema(schemas.AddType("snapshotListOutput", SnapshotListOutput{}))
systemBackupSchema(schemas.AddType("systemBackup", SystemBackup{}))
systemRestoreSchema(schemas.AddType("systemRestore", SystemRestore{}))
snapshotCRListOutputSchema(schemas.AddType("snapshotCRListOutput", SnapshotCRListOutput{}))
return schemas
}
func nodeSchema(node *client.Schema) {
node.CollectionMethods = []string{"GET"}
node.ResourceMethods = []string{"GET", "PUT"}
node.ResourceActions = map[string]client.Action{
"diskUpdate": {
Input: "diskUpdateInput",
Output: "node",
},
}
allowScheduling := node.ResourceFields["allowScheduling"]
allowScheduling.Required = true
allowScheduling.Unique = false
node.ResourceFields["allowScheduling"] = allowScheduling
evictionRequested := node.ResourceFields["evictionRequested"]
evictionRequested.Required = true
evictionRequested.Unique = false
node.ResourceFields["evictionRequested"] = evictionRequested
node.ResourceFields["disks"] = client.Field{
Type: "map[diskInfo]",
Nullable: true,
}
conditions := node.ResourceFields["conditions"]
conditions.Type = "map[nodeCondition]"
node.ResourceFields["conditions"] = conditions
tags := node.ResourceFields["tags"]
tags.Create = true
node.ResourceFields["tags"] = tags
}
func diskSchema(diskUpdateInput *client.Schema) {
disks := diskUpdateInput.ResourceFields["disks"]
disks.Type = "array[diskUpdate]"
diskUpdateInput.ResourceFields["disks"] = disks
}
func diskInfoSchema(diskInfo *client.Schema) {
conditions := diskInfo.ResourceFields["conditions"]
conditions.Type = "map[diskCondition]"
diskInfo.ResourceFields["conditions"] = conditions
}
func engineImageSchema(engineImage *client.Schema) {
engineImage.CollectionMethods = []string{"GET", "POST"}
engineImage.ResourceMethods = []string{"GET", "DELETE"}
image := engineImage.ResourceFields["image"]
image.Create = true
image.Required = true
image.Unique = true
engineImage.ResourceFields["image"] = image
}
func backingImageSchema(backingImage *client.Schema) {
backingImage.CollectionMethods = []string{"GET", "POST"}
backingImage.ResourceMethods = []string{"GET", "DELETE"}
backingImage.ResourceActions = map[string]client.Action{
"backingImageCleanup": {
Input: "backingImageCleanupInput",
Output: "backingImage",
},
BackingImageUpload: {},
"backupBackingImageCreate": {},
}
name := backingImage.ResourceFields["name"]
name.Required = true
name.Unique = true
name.Create = true
backingImage.ResourceFields["name"] = name
expectedChecksum := backingImage.ResourceFields["expectedChecksum"]
expectedChecksum.Create = true
backingImage.ResourceFields["expectedChecksum"] = expectedChecksum
sourceType := backingImage.ResourceFields["sourceType"]
sourceType.Required = true
sourceType.Create = true
backingImage.ResourceFields["sourceType"] = sourceType
parameters := backingImage.ResourceFields["parameters"]
parameters.Type = "map[string]"
parameters.Required = true
parameters.Create = true
backingImage.ResourceFields["parameters"] = parameters
diskFileStatusMap := backingImage.ResourceFields["diskFileStatusMap"]
diskFileStatusMap.Type = "map[backingImageDiskFileStatus]"
backingImage.ResourceFields["diskFileStatusMap"] = diskFileStatusMap
}
func backupBackingImageSchema(backupBackingImage *client.Schema) {
backupBackingImage.CollectionMethods = []string{"GET"}
backupBackingImage.ResourceMethods = []string{"GET", "DELETE"}
backupBackingImage.ResourceActions = map[string]client.Action{
"backupBackingImageRestore": {},
}
}
func recurringJobSchema(job *client.Schema) {
job.CollectionMethods = []string{"GET", "POST"}
job.ResourceMethods = []string{"GET", "PUT", "DELETE"}
name := job.ResourceFields["name"]
name.Required = true
name.Unique = true
name.Create = true
job.ResourceFields["name"] = name
groups := job.ResourceFields["groups"]
groups.Type = "array[string]"
groups.Nullable = true
job.ResourceFields["groups"] = groups
cron := job.ResourceFields["cron"]
cron.Required = true
cron.Unique = false
cron.Create = true
job.ResourceFields["cron"] = cron
retain := job.ResourceFields["retain"]
retain.Required = true
retain.Unique = false
retain.Create = true
job.ResourceFields["retain"] = retain
concurrency := job.ResourceFields["concurrency"]
concurrency.Required = true
concurrency.Unique = false
concurrency.Create = true
job.ResourceFields["concurrency"] = concurrency
labels := job.ResourceFields["labels"]
labels.Type = "map[string]"
labels.Nullable = true
job.ResourceFields["labels"] = labels
}
func kubernetesStatusSchema(status *client.Schema) {
workloadsStatus := status.ResourceFields["workloadsStatus"]
workloadsStatus.Type = "array[workloadStatus]"
status.ResourceFields["workloadsStatus"] = workloadsStatus
}
func backupTargetSchema(backupTarget *client.Schema) {
backupTarget.CollectionMethods = []string{"GET"}
backupTarget.ResourceMethods = []string{"GET", "PUT"}
backupTarget.ResourceActions = map[string]client.Action{
"backupTargetSync": {
Input: "syncBackupResource",
Output: "backupTargetListOutput",
},
}
}
func backupVolumeSchema(backupVolume *client.Schema) {
backupVolume.CollectionMethods = []string{"GET"}
backupVolume.ResourceMethods = []string{"GET", "PUT", "DELETE"}
backupVolume.ResourceActions = map[string]client.Action{
"backupList": {
Output: "backupListOutput",
},
"backupGet": {
Input: "backupInput",
Output: "backup",
},
"backupDelete": {
Input: "backupInput",
Output: "backupVolume",
},
"backupVolumeSync": {
Input: "syncBackupResource",
Output: "backupVolumeListOutput",
},
}
}
func settingSchema(setting *client.Schema) {
setting.CollectionMethods = []string{"GET"}
setting.ResourceMethods = []string{"GET", "PUT"}
settingName := setting.ResourceFields["name"]
settingName.Required = true
settingName.Unique = true
setting.ResourceFields["name"] = settingName
settingValue := setting.ResourceFields["value"]
settingValue.Required = true
settingValue.Update = true
setting.ResourceFields["value"] = settingValue
setting.ResourceFields["definition"] = client.Field{
Type: "settingDefinition",
Nullable: false,
}
}
func volumeSchema(volume *client.Schema) {
volume.CollectionMethods = []string{"GET", "POST"}
volume.ResourceMethods = []string{"GET", "DELETE"}
volume.ResourceActions = map[string]client.Action{
"attach": {
Input: "attachInput",
Output: "volume",
},
"detach": {
Input: "detachInput",
Output: "volume",
},
"salvage": {
Input: "salvageInput",
Output: "volume",
},
"activate": {
Input: "activateInput",
Output: "volume",
},
"expand": {
Input: "expandInput",
Output: "volume",
},
"cancelExpansion": {
Output: "volume",
},
"trimFilesystem": {
Output: "volume",
},
"snapshotPurge": {
Output: "volume",
},
"snapshotCreate": {
Input: "snapshotInput",
Output: "snapshot",
},
"snapshotGet": {
Input: "snapshotInput",
Output: "snapshot",
},
"snapshotList": {
Output: "snapshotListOutput",
},
"snapshotDelete": {
Input: "snapshotInput",
Output: "volume",
},
"snapshotRevert": {
Input: "snapshotInput",
Output: "snapshot",
},
"snapshotBackup": {
Input: "snapshotInput",
Output: "volume",
},
"snapshotCRCreate": {
Input: "snapshotCRInput",
Output: "snapshotCR",
},
"snapshotCRGet": {
Input: "snapshotCRInput",
Output: "snapshotCR",
},
"snapshotCRList": {
Output: "snapshotCRListOutput",
},
"snapshotCRDelete": {
Input: "snapshotCRInput",
Output: "empty",
},
"recurringJobAdd": {
Input: "volumeRecurringJobInput",
Output: "volumeRecurringJob",
},
"recurringJobList": {
Output: "volumeRecurringJob",
},
"recurringJobDelete": {
Input: "volumeRecurringJobInput",
Output: "volumeRecurringJob",
},
"updateReplicaCount": {
Input: "UpdateReplicaCountInput",
},
"updateReplicaAutoBalance": {
Input: "ReplicaAutoBalance",
},
"updateDataLocality": {
Input: "UpdateDataLocalityInput",
},
"updateAccessMode": {
Input: "UpdateAccessModeInput",