-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathview.go
More file actions
1100 lines (1053 loc) · 38.2 KB
/
view.go
File metadata and controls
1100 lines (1053 loc) · 38.2 KB
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
// Code generated by goa v3.19.1, DO NOT EDIT.
//
// control-plane views
//
// Command:
// $ goa gen github.com/pgEdge/control-plane/api/design
package views
import (
goa "goa.design/goa/v3/pkg"
)
// DatabaseCollection is the viewed result type that is projected based on a
// view.
type DatabaseCollection struct {
// Type to project
Projected DatabaseCollectionView
// View to render
View string
}
// Database is the viewed result type that is projected based on a view.
type Database struct {
// Type to project
Projected *DatabaseView
// View to render
View string
}
// DatabaseCollectionView is a type that runs validations on a projected type.
type DatabaseCollectionView []*DatabaseView
// DatabaseView is a type that runs validations on a projected type.
type DatabaseView struct {
// Unique identifier for the database.
ID *string
// Unique identifier for the databases's owner.
TenantID *string
// The time that the database was created.
CreatedAt *string
// The time that the database was last updated.
UpdatedAt *string
// Current state of the database.
State *string
// All of the instances in the database.
Instances InstanceCollectionView
// The user-provided specification for the database.
Spec *DatabaseSpecView
}
// InstanceCollectionView is a type that runs validations on a projected type.
type InstanceCollectionView []*InstanceView
// InstanceView is a type that runs validations on a projected type.
type InstanceView struct {
// Unique identifier for the instance.
ID *string
// The ID of the host this instance is running on.
HostID *string
// The Spock node name for this instance.
NodeName *string
// The time that the instance was created.
CreatedAt *string
// The time that the instance was last modified.
UpdatedAt *string
// The time that the instance status information was last updated.
StatusUpdatedAt *string
State *string
PatroniState *string
Role *string
// The current spock.readonly setting.
ReadOnly *string
// True if this instance is pending to be restarted from a configuration change.
PendingRestart *bool
// True if Patroni has been paused for this instance.
PatroniPaused *bool
// The version of Postgres for this instance.
PostgresVersion *string
// The version of Spock for this instance.
SpockVersion *string
// The hostname of the host that's running this instance.
Hostname *string
// The IPv4 address of the host that's running this instance.
Ipv4Address *string
// The host port that Postgres is listening on for this instance.
Port *int
// Status information for this instance's Spock subscriptions.
Subscriptions []*InstanceSubscriptionView
// An error message if the instance is in an error state.
Error *string
}
// InstanceSubscriptionView is a type that runs validations on a projected type.
type InstanceSubscriptionView struct {
// The Spock node name of the provider for this subscription.
ProviderNode *string
// The name of the subscription.
Name *string
// The current status of the subscription.
Status *string
}
// DatabaseSpecView is a type that runs validations on a projected type.
type DatabaseSpecView struct {
// The name of the Postgres database.
DatabaseName *string
// The major version of the Postgres database.
PostgresVersion *string
// The major version of the Spock extension.
SpockVersion *string
// The port used by the Postgres database.
Port *int
// Prevents deletion when true.
DeletionProtection *bool
// The storage class to use for the database. The possible values and defaults
// depend on the orchestrator.
StorageClass *string
// The size of the storage in SI or IEC notation. Support for this value
// depends on the orchestrator and storage class.
StorageSize *string
// The number of CPUs to allocate for the database and to use for tuning
// Postgres. Defaults to the number of available CPUs on the host. Can include
// an SI suffix, e.g. '500m' for 500 millicpus. Whether this limit will be
// enforced depends on the orchestrator.
Cpus *string
// The amount of memory in SI or IEC notation to allocate for the database and
// to use for tuning Postgres. Defaults to the total available memory on the
// host. Whether this limit will be enforced depends on the orchestrator.
Memory *string
// The Spock nodes for this database.
Nodes []*DatabaseNodeSpecView
// The users to create for this database.
DatabaseUsers []*DatabaseUserSpecView
// The feature flags for this database.
Features map[string]string
// The backup configuration for this database.
BackupConfig *BackupConfigSpecView
// The restore configuration for this database.
RestoreConfig *RestoreConfigSpecView
// Additional postgresql.conf settings. Will be merged with the settings
// provided by control-plane.
PostgresqlConf map[string]any
// A list of extra volumes to mount. Each entry defines a host and container
// path.
ExtraVolumes []*ExtraVolumesSpecView
}
// DatabaseNodeSpecView is a type that runs validations on a projected type.
type DatabaseNodeSpecView struct {
// The name of the database node.
Name *string
// The IDs of the hosts that should run this node. When multiple hosts are
// specified, one host will chosen as a primary and the others will be read
// replicas.
HostIds []string
// The major version of Postgres for this node. Overrides the Postgres version
// set in the DatabaseSpec.
PostgresVersion *string
// The port used by the Postgres database for this node. Overrides the Postgres
// port set in the DatabaseSpec.
Port *int
// The storage class to use for the database on this node. The possible values
// and defaults depend on the orchestrator.
StorageClass *string
// The size of the storage for this node in SI or IEC notation. Support for
// this value depends on the orchestrator and storage class.
StorageSize *string
// The number of CPUs to allocate for the database on this node and to use for
// tuning Postgres. Defaults to the number of available CPUs on the host. Can
// include an SI suffix, e.g. '500m' for 500 millicpus. Whether this limit will
// be enforced depends on the orchestrator.
Cpus *string
// The amount of memory in SI or IEC notation to allocate for the database on
// this node and to use for tuning Postgres. Defaults to the total available
// memory on the host. Whether this limit will be enforced depends on the
// orchestrator.
Memory *string
// Additional postgresql.conf settings for this particular node. Will be merged
// with the settings provided by control-plane.
PostgresqlConf map[string]any
// The backup configuration for this node. Overrides the backup configuration
// set in the DatabaseSpec.
BackupConfig *BackupConfigSpecView
// The restore configuration for this node. Overrides the restore configuration
// set in the DatabaseSpec.
RestoreConfig *RestoreConfigSpecView
// Optional list of external volumes to mount for this node only.
ExtraVolumes []*ExtraVolumesSpecView
}
// BackupConfigSpecView is a type that runs validations on a projected type.
type BackupConfigSpecView struct {
// The backup provider for this backup configuration.
Provider *string
// The repositories for this backup configuration.
Repositories []*BackupRepositorySpecView
// The schedules for this backup configuration.
Schedules []*BackupScheduleSpecView
}
// BackupRepositorySpecView is a type that runs validations on a projected type.
type BackupRepositorySpecView struct {
// The unique identifier of this repository.
ID *string
// The type of this repository.
Type *string
// The S3 bucket name for this repository. Only applies when type = 's3'.
S3Bucket *string
// The region of the S3 bucket for this repository. Only applies when type =
// 's3'.
S3Region *string
// The optional S3 endpoint for this repository. Only applies when type = 's3'.
S3Endpoint *string
// An optional AWS access key ID to use for this repository. If not provided,
// pgbackrest will use the default credential provider chain.
S3Key *string
// The corresponding secret for the AWS access key ID in s3_key.
S3KeySecret *string
// The GCS bucket name for this repository. Only applies when type = 'gcs'.
GcsBucket *string
// The optional GCS endpoint for this repository. Only applies when type =
// 'gcs'.
GcsEndpoint *string
// Optional base64-encoded private key data. If omitted, pgbackrest will use
// the service account attached to the instance profile.
GcsKey *string
// The Azure account name for this repository. Only applies when type = 'azure'.
AzureAccount *string
// The Azure container name for this repository. Only applies when type =
// 'azure'.
AzureContainer *string
// The optional Azure endpoint for this repository. Only applies when type =
// 'azure'.
AzureEndpoint *string
// An optional Azure storage account access key to use for this repository. If
// not provided, pgbackrest will use the VM's managed identity.
AzureKey *string
// The count of full backups to retain or the time to retain full backups.
RetentionFull *int
// The type of measure used for retention_full.
RetentionFullType *string
// The base path within the repository to store backups. Required for type =
// 'posix' and 'cifs'.
BasePath *string
// Additional options to apply to this repository.
CustomOptions map[string]string
}
// BackupScheduleSpecView is a type that runs validations on a projected type.
type BackupScheduleSpecView struct {
// The unique identifier for this backup schedule.
ID *string
// The type of backup to take on this schedule.
Type *string
// The cron expression for this schedule.
CronExpression *string
}
// RestoreConfigSpecView is a type that runs validations on a projected type.
type RestoreConfigSpecView struct {
// The backup provider for this restore configuration.
Provider *string
// The ID of the database to restore this database from.
SourceDatabaseID *string
// The name of the node to restore this database from.
SourceNodeName *string
// The name of the database in this repository. This database will be renamed
// to the database_name in the DatabaseSpec.
SourceDatabaseName *string
// The repository to restore this database from.
Repository *RestoreRepositorySpecView
// Additional options to use when restoring this database. If omitted, the
// database will be restored to the latest point in the given repository.
RestoreOptions map[string]string
}
// RestoreRepositorySpecView is a type that runs validations on a projected
// type.
type RestoreRepositorySpecView struct {
// The unique identifier of this repository.
ID *string
// The type of this repository.
Type *string
// The S3 bucket name for this repository. Only applies when type = 's3'.
S3Bucket *string
// The region of the S3 bucket for this repository. Only applies when type =
// 's3'.
S3Region *string
// The optional S3 endpoint for this repository. Only applies when type = 's3'.
S3Endpoint *string
// An optional AWS access key ID to use for this repository. If not provided,
// pgbackrest will use the default credential provider chain.
S3Key *string
// The corresponding secret for the AWS access key ID in s3_key.
S3KeySecret *string
// The GCS bucket name for this repository. Only applies when type = 'gcs'.
GcsBucket *string
// The optional GCS endpoint for this repository. Only applies when type =
// 'gcs'.
GcsEndpoint *string
// Optional base64-encoded private key data. If omitted, pgbackrest will use
// the service account attached to the instance profile.
GcsKey *string
// The Azure account name for this repository. Only applies when type = 'azure'.
AzureAccount *string
// The Azure container name for this repository. Only applies when type =
// 'azure'.
AzureContainer *string
// The optional Azure endpoint for this repository. Only applies when type =
// 'azure'.
AzureEndpoint *string
// An optional Azure storage account access key to use for this repository. If
// not provided, pgbackrest will use the VM's managed identity.
AzureKey *string
// The base path within the repository to store backups. Required for type =
// 'posix' and 'cifs'.
BasePath *string
// Additional options to apply to this repository.
CustomOptions map[string]string
}
// ExtraVolumesSpecView is a type that runs validations on a projected type.
type ExtraVolumesSpecView struct {
// The host path for the volume.
HostPath *string
// The path inside the container where the volume will be mounted.
DestinationPath *string
}
// DatabaseUserSpecView is a type that runs validations on a projected type.
type DatabaseUserSpecView struct {
// The username for this database user.
Username *string
// The password for this database user.
Password *string
// If true, this user will be granted database ownership.
DbOwner *bool
// The attributes to assign to this database user.
Attributes []string
// The roles to assign to this database user.
Roles []string
}
// CreateDatabaseResponseView is a type that runs validations on a projected
// type.
type CreateDatabaseResponseView struct {
// The task that will create this database.
Task *TaskView
// The database being created.
Database *DatabaseView
}
// TaskView is a type that runs validations on a projected type.
type TaskView struct {
// The parent task ID of the task.
ParentID *string
// The database ID of the task.
DatabaseID *string
// The name of the node that the task is operating on.
NodeName *string
// The ID of the instance that the task is operating on.
InstanceID *string
// The ID of the host that the task is running on.
HostID *string
// The unique ID of the task.
TaskID *string
// The time when the task was created.
CreatedAt *string
// The time when the task was completed.
CompletedAt *string
// The type of the task.
Type *string
// The status of the task.
Status *string
// The error message if the task failed.
Error *string
}
// UpdateDatabaseResponseView is a type that runs validations on a projected
// type.
type UpdateDatabaseResponseView struct {
// The task that will update this database.
Task *TaskView
// The database being updated.
Database *DatabaseView
}
// RestoreDatabaseResponseView is a type that runs validations on a projected
// type.
type RestoreDatabaseResponseView struct {
// The task that will restore this database.
Task *TaskView
// The tasks that will restore each database node.
NodeTasks []*TaskView
// The database being restored.
Database *DatabaseView
}
var (
// DatabaseCollectionMap is a map indexing the attribute names of
// DatabaseCollection by view name.
DatabaseCollectionMap = map[string][]string{
"default": {
"id",
"tenant_id",
"created_at",
"updated_at",
"state",
"instances",
"spec",
},
"abbreviated": {
"id",
"tenant_id",
"created_at",
"updated_at",
"state",
"instances",
},
}
// DatabaseMap is a map indexing the attribute names of Database by view name.
DatabaseMap = map[string][]string{
"default": {
"id",
"tenant_id",
"created_at",
"updated_at",
"state",
"instances",
"spec",
},
"abbreviated": {
"id",
"tenant_id",
"created_at",
"updated_at",
"state",
"instances",
},
}
// InstanceCollectionMap is a map indexing the attribute names of
// InstanceCollection by view name.
InstanceCollectionMap = map[string][]string{
"default": {
"id",
"host_id",
"node_name",
"created_at",
"updated_at",
"status_updated_at",
"state",
"patroni_state",
"role",
"read_only",
"pending_restart",
"patroni_paused",
"postgres_version",
"spock_version",
"hostname",
"ipv4_address",
"port",
"subscriptions",
"error",
},
"abbreviated": {
"id",
"host_id",
"node_name",
"state",
},
}
// InstanceMap is a map indexing the attribute names of Instance by view name.
InstanceMap = map[string][]string{
"default": {
"id",
"host_id",
"node_name",
"created_at",
"updated_at",
"status_updated_at",
"state",
"patroni_state",
"role",
"read_only",
"pending_restart",
"patroni_paused",
"postgres_version",
"spock_version",
"hostname",
"ipv4_address",
"port",
"subscriptions",
"error",
},
"abbreviated": {
"id",
"host_id",
"node_name",
"state",
},
}
)
// ValidateDatabaseCollection runs the validations defined on the viewed result
// type DatabaseCollection.
func ValidateDatabaseCollection(result DatabaseCollection) (err error) {
switch result.View {
case "default", "":
err = ValidateDatabaseCollectionView(result.Projected)
case "abbreviated":
err = ValidateDatabaseCollectionViewAbbreviated(result.Projected)
default:
err = goa.InvalidEnumValueError("view", result.View, []any{"default", "abbreviated"})
}
return
}
// ValidateDatabase runs the validations defined on the viewed result type
// Database.
func ValidateDatabase(result *Database) (err error) {
switch result.View {
case "default", "":
err = ValidateDatabaseView(result.Projected)
case "abbreviated":
err = ValidateDatabaseViewAbbreviated(result.Projected)
default:
err = goa.InvalidEnumValueError("view", result.View, []any{"default", "abbreviated"})
}
return
}
// ValidateDatabaseCollectionView runs the validations defined on
// DatabaseCollectionView using the "default" view.
func ValidateDatabaseCollectionView(result DatabaseCollectionView) (err error) {
for _, item := range result {
if err2 := ValidateDatabaseView(item); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
return
}
// ValidateDatabaseCollectionViewAbbreviated runs the validations defined on
// DatabaseCollectionView using the "abbreviated" view.
func ValidateDatabaseCollectionViewAbbreviated(result DatabaseCollectionView) (err error) {
for _, item := range result {
if err2 := ValidateDatabaseViewAbbreviated(item); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
return
}
// ValidateDatabaseView runs the validations defined on DatabaseView using the
// "default" view.
func ValidateDatabaseView(result *DatabaseView) (err error) {
if result.ID == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("id", "result"))
}
if result.CreatedAt == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("created_at", "result"))
}
if result.UpdatedAt == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("updated_at", "result"))
}
if result.State == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("state", "result"))
}
if result.ID != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.id", *result.ID, goa.FormatUUID))
}
if result.TenantID != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.tenant_id", *result.TenantID, goa.FormatUUID))
}
if result.CreatedAt != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.created_at", *result.CreatedAt, goa.FormatDateTime))
}
if result.UpdatedAt != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.updated_at", *result.UpdatedAt, goa.FormatDateTime))
}
if result.State != nil {
if !(*result.State == "creating" || *result.State == "modifying" || *result.State == "available" || *result.State == "deleting" || *result.State == "degraded" || *result.State == "unknown") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.state", *result.State, []any{"creating", "modifying", "available", "deleting", "degraded", "unknown"}))
}
}
if result.Spec != nil {
if err2 := ValidateDatabaseSpecView(result.Spec); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
if result.Instances != nil {
if err2 := ValidateInstanceCollectionView(result.Instances); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
return
}
// ValidateDatabaseViewAbbreviated runs the validations defined on DatabaseView
// using the "abbreviated" view.
func ValidateDatabaseViewAbbreviated(result *DatabaseView) (err error) {
if result.ID == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("id", "result"))
}
if result.CreatedAt == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("created_at", "result"))
}
if result.UpdatedAt == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("updated_at", "result"))
}
if result.State == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("state", "result"))
}
if result.ID != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.id", *result.ID, goa.FormatUUID))
}
if result.TenantID != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.tenant_id", *result.TenantID, goa.FormatUUID))
}
if result.CreatedAt != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.created_at", *result.CreatedAt, goa.FormatDateTime))
}
if result.UpdatedAt != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.updated_at", *result.UpdatedAt, goa.FormatDateTime))
}
if result.State != nil {
if !(*result.State == "creating" || *result.State == "modifying" || *result.State == "available" || *result.State == "deleting" || *result.State == "degraded" || *result.State == "unknown") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.state", *result.State, []any{"creating", "modifying", "available", "deleting", "degraded", "unknown"}))
}
}
if result.Instances != nil {
if err2 := ValidateInstanceCollectionViewAbbreviated(result.Instances); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
return
}
// ValidateInstanceCollectionView runs the validations defined on
// InstanceCollectionView using the "default" view.
func ValidateInstanceCollectionView(result InstanceCollectionView) (err error) {
for _, item := range result {
if err2 := ValidateInstanceView(item); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
return
}
// ValidateInstanceCollectionViewAbbreviated runs the validations defined on
// InstanceCollectionView using the "abbreviated" view.
func ValidateInstanceCollectionViewAbbreviated(result InstanceCollectionView) (err error) {
for _, item := range result {
if err2 := ValidateInstanceViewAbbreviated(item); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
return
}
// ValidateInstanceView runs the validations defined on InstanceView using the
// "default" view.
func ValidateInstanceView(result *InstanceView) (err error) {
if result.ID == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("id", "result"))
}
if result.HostID == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("host_id", "result"))
}
if result.NodeName == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("node_name", "result"))
}
if result.CreatedAt == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("created_at", "result"))
}
if result.UpdatedAt == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("updated_at", "result"))
}
if result.State == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("state", "result"))
}
if result.ID != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.id", *result.ID, goa.FormatUUID))
}
if result.HostID != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.host_id", *result.HostID, goa.FormatUUID))
}
if result.CreatedAt != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.created_at", *result.CreatedAt, goa.FormatDateTime))
}
if result.UpdatedAt != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.updated_at", *result.UpdatedAt, goa.FormatDateTime))
}
if result.StatusUpdatedAt != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.status_updated_at", *result.StatusUpdatedAt, goa.FormatDateTime))
}
if result.State != nil {
if !(*result.State == "creating" || *result.State == "modifying" || *result.State == "backing_up" || *result.State == "available" || *result.State == "degraded" || *result.State == "failed" || *result.State == "unknown") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.state", *result.State, []any{"creating", "modifying", "backing_up", "available", "degraded", "failed", "unknown"}))
}
}
if result.PatroniState != nil {
if !(*result.PatroniState == "stopping" || *result.PatroniState == "stopped" || *result.PatroniState == "stop failed" || *result.PatroniState == "crashed" || *result.PatroniState == "running" || *result.PatroniState == "starting" || *result.PatroniState == "start failed" || *result.PatroniState == "restarting" || *result.PatroniState == "restart failed" || *result.PatroniState == "initializing new cluster" || *result.PatroniState == "initdb failed" || *result.PatroniState == "running custom bootstrap script" || *result.PatroniState == "custom bootstrap failed" || *result.PatroniState == "creating replica" || *result.PatroniState == "unknown") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.patroni_state", *result.PatroniState, []any{"stopping", "stopped", "stop failed", "crashed", "running", "starting", "start failed", "restarting", "restart failed", "initializing new cluster", "initdb failed", "running custom bootstrap script", "custom bootstrap failed", "creating replica", "unknown"}))
}
}
if result.Role != nil {
if !(*result.Role == "replica" || *result.Role == "primary") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.role", *result.Role, []any{"replica", "primary"}))
}
}
if result.Ipv4Address != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.ipv4_address", *result.Ipv4Address, goa.FormatIPv4))
}
for _, e := range result.Subscriptions {
if e != nil {
if err2 := ValidateInstanceSubscriptionView(e); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
}
return
}
// ValidateInstanceViewAbbreviated runs the validations defined on InstanceView
// using the "abbreviated" view.
func ValidateInstanceViewAbbreviated(result *InstanceView) (err error) {
if result.ID == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("id", "result"))
}
if result.HostID == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("host_id", "result"))
}
if result.NodeName == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("node_name", "result"))
}
if result.State == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("state", "result"))
}
if result.ID != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.id", *result.ID, goa.FormatUUID))
}
if result.HostID != nil {
err = goa.MergeErrors(err, goa.ValidateFormat("result.host_id", *result.HostID, goa.FormatUUID))
}
if result.State != nil {
if !(*result.State == "creating" || *result.State == "modifying" || *result.State == "backing_up" || *result.State == "available" || *result.State == "degraded" || *result.State == "failed" || *result.State == "unknown") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.state", *result.State, []any{"creating", "modifying", "backing_up", "available", "degraded", "failed", "unknown"}))
}
}
return
}
// ValidateInstanceSubscriptionView runs the validations defined on
// InstanceSubscriptionView.
func ValidateInstanceSubscriptionView(result *InstanceSubscriptionView) (err error) {
if result.ProviderNode == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("provider_node", "result"))
}
if result.Name == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("name", "result"))
}
if result.Status == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("status", "result"))
}
return
}
// ValidateDatabaseSpecView runs the validations defined on DatabaseSpecView.
func ValidateDatabaseSpecView(result *DatabaseSpecView) (err error) {
if result.DatabaseName == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("database_name", "result"))
}
if result.Nodes == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("nodes", "result"))
}
if result.PostgresVersion != nil {
if !(*result.PostgresVersion == "16" || *result.PostgresVersion == "17") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.postgres_version", *result.PostgresVersion, []any{"16", "17"}))
}
}
if result.SpockVersion != nil {
if !(*result.SpockVersion == "4") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.spock_version", *result.SpockVersion, []any{"4"}))
}
}
for _, e := range result.Nodes {
if e != nil {
if err2 := ValidateDatabaseNodeSpecView(e); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
}
for _, e := range result.DatabaseUsers {
if e != nil {
if err2 := ValidateDatabaseUserSpecView(e); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
}
if result.BackupConfig != nil {
if err2 := ValidateBackupConfigSpecView(result.BackupConfig); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
if result.RestoreConfig != nil {
if err2 := ValidateRestoreConfigSpecView(result.RestoreConfig); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
for _, e := range result.ExtraVolumes {
if e != nil {
if err2 := ValidateExtraVolumesSpecView(e); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
}
return
}
// ValidateDatabaseNodeSpecView runs the validations defined on
// DatabaseNodeSpecView.
func ValidateDatabaseNodeSpecView(result *DatabaseNodeSpecView) (err error) {
if result.Name == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("name", "result"))
}
if result.HostIds == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("host_ids", "result"))
}
if result.Name != nil {
err = goa.MergeErrors(err, goa.ValidatePattern("result.name", *result.Name, "n[0-9]+"))
}
if len(result.HostIds) < 1 {
err = goa.MergeErrors(err, goa.InvalidLengthError("result.host_ids", result.HostIds, len(result.HostIds), 1, true))
}
for _, e := range result.HostIds {
err = goa.MergeErrors(err, goa.ValidateFormat("result.host_ids[*]", e, goa.FormatUUID))
}
if result.PostgresVersion != nil {
if !(*result.PostgresVersion == "16" || *result.PostgresVersion == "17") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.postgres_version", *result.PostgresVersion, []any{"16", "17"}))
}
}
if result.BackupConfig != nil {
if err2 := ValidateBackupConfigSpecView(result.BackupConfig); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
if result.RestoreConfig != nil {
if err2 := ValidateRestoreConfigSpecView(result.RestoreConfig); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
for _, e := range result.ExtraVolumes {
if e != nil {
if err2 := ValidateExtraVolumesSpecView(e); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
}
return
}
// ValidateBackupConfigSpecView runs the validations defined on
// BackupConfigSpecView.
func ValidateBackupConfigSpecView(result *BackupConfigSpecView) (err error) {
if result.Repositories == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("repositories", "result"))
}
if result.Provider != nil {
if !(*result.Provider == "pgbackrest") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.provider", *result.Provider, []any{"pgbackrest"}))
}
}
if len(result.Repositories) < 1 {
err = goa.MergeErrors(err, goa.InvalidLengthError("result.repositories", result.Repositories, len(result.Repositories), 1, true))
}
for _, e := range result.Repositories {
if e != nil {
if err2 := ValidateBackupRepositorySpecView(e); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
}
for _, e := range result.Schedules {
if e != nil {
if err2 := ValidateBackupScheduleSpecView(e); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
}
return
}
// ValidateBackupRepositorySpecView runs the validations defined on
// BackupRepositorySpecView.
func ValidateBackupRepositorySpecView(result *BackupRepositorySpecView) (err error) {
if result.Type == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("type", "result"))
}
if result.Type != nil {
if !(*result.Type == "s3" || *result.Type == "gcs" || *result.Type == "azure" || *result.Type == "posix" || *result.Type == "cifs") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.type", *result.Type, []any{"s3", "gcs", "azure", "posix", "cifs"}))
}
}
if result.RetentionFullType != nil {
if !(*result.RetentionFullType == "time" || *result.RetentionFullType == "count") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.retention_full_type", *result.RetentionFullType, []any{"time", "count"}))
}
}
return
}
// ValidateBackupScheduleSpecView runs the validations defined on
// BackupScheduleSpecView.
func ValidateBackupScheduleSpecView(result *BackupScheduleSpecView) (err error) {
if result.ID == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("id", "result"))
}
if result.Type == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("type", "result"))
}
if result.CronExpression == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("cron_expression", "result"))
}
if result.Type != nil {
if !(*result.Type == "full" || *result.Type == "incr") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.type", *result.Type, []any{"full", "incr"}))
}
}
return
}
// ValidateRestoreConfigSpecView runs the validations defined on
// RestoreConfigSpecView.
func ValidateRestoreConfigSpecView(result *RestoreConfigSpecView) (err error) {
if result.SourceDatabaseID == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("source_database_id", "result"))
}
if result.SourceNodeName == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("source_node_name", "result"))
}
if result.SourceDatabaseName == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("source_database_name", "result"))
}
if result.Repository == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("repository", "result"))
}
if result.Provider != nil {
if !(*result.Provider == "pgbackrest") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.provider", *result.Provider, []any{"pgbackrest"}))
}
}
if result.Repository != nil {
if err2 := ValidateRestoreRepositorySpecView(result.Repository); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
return
}
// ValidateRestoreRepositorySpecView runs the validations defined on
// RestoreRepositorySpecView.
func ValidateRestoreRepositorySpecView(result *RestoreRepositorySpecView) (err error) {
if result.Type == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("type", "result"))
}
if result.Type != nil {
if !(*result.Type == "s3" || *result.Type == "gcs" || *result.Type == "azure" || *result.Type == "posix" || *result.Type == "cifs") {
err = goa.MergeErrors(err, goa.InvalidEnumValueError("result.type", *result.Type, []any{"s3", "gcs", "azure", "posix", "cifs"}))
}
}
return
}
// ValidateExtraVolumesSpecView runs the validations defined on
// ExtraVolumesSpecView.
func ValidateExtraVolumesSpecView(result *ExtraVolumesSpecView) (err error) {
if result.HostPath == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("host_path", "result"))
}
if result.DestinationPath == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("destination_path", "result"))
}
return
}
// ValidateDatabaseUserSpecView runs the validations defined on
// DatabaseUserSpecView.
func ValidateDatabaseUserSpecView(result *DatabaseUserSpecView) (err error) {
if result.Username == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("username", "result"))
}
if result.Password == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("password", "result"))
}
return
}