This repository has been archived by the owner on Dec 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
global.go
781 lines (599 loc) · 16.5 KB
/
global.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
// Code generated by go-swagger; DO NOT EDIT.
// Copyright 2019 HAProxy Technologies
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Global Global
//
// HAProxy global configuration
//
// swagger:model global
type Global struct {
// CPU maps
CPUMaps []*CPUMap `json:"cpu_maps"`
// runtime a p is
RuntimeAPIs []*RuntimeAPI `json:"runtime_apis"`
// chroot
// Pattern: ^[^\s]+$
Chroot string `json:"chroot,omitempty"`
// daemon
// Enum: [enabled disabled]
Daemon string `json:"daemon,omitempty"`
// external check
ExternalCheck bool `json:"external_check,omitempty"`
// group
// Pattern: ^[^\s]+$
Group string `json:"group,omitempty"`
// log send hostname
LogSendHostname *GlobalLogSendHostname `json:"log_send_hostname,omitempty"`
// lua loads
LuaLoads []*LuaLoad `json:"lua_loads"`
// master worker
MasterWorker bool `json:"master-worker,omitempty"`
// maxconn
Maxconn int64 `json:"maxconn,omitempty"`
// nbproc
Nbproc int64 `json:"nbproc,omitempty"`
// nbthread
Nbthread int64 `json:"nbthread,omitempty"`
// pidfile
Pidfile string `json:"pidfile,omitempty"`
// ssl default bind ciphers
SslDefaultBindCiphers string `json:"ssl_default_bind_ciphers,omitempty"`
// ssl default bind ciphersuites
SslDefaultBindCiphersuites string `json:"ssl_default_bind_ciphersuites,omitempty"`
// ssl default bind options
SslDefaultBindOptions string `json:"ssl_default_bind_options,omitempty"`
// ssl default server ciphers
SslDefaultServerCiphers string `json:"ssl_default_server_ciphers,omitempty"`
// ssl default server ciphersuites
SslDefaultServerCiphersuites string `json:"ssl_default_server_ciphersuites,omitempty"`
// ssl default server options
SslDefaultServerOptions string `json:"ssl_default_server_options,omitempty"`
// ssl mode async
// Enum: [enabled disabled]
SslModeAsync string `json:"ssl_mode_async,omitempty"`
// stats timeout
StatsTimeout *int64 `json:"stats_timeout,omitempty"`
// tune ssl default dh param
TuneSslDefaultDhParam int64 `json:"tune_ssl_default_dh_param,omitempty"`
// user
// Pattern: ^[^\s]+$
User string `json:"user,omitempty"`
}
// Validate validates this global
func (m *Global) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCPUMaps(formats); err != nil {
res = append(res, err)
}
if err := m.validateRuntimeAPIs(formats); err != nil {
res = append(res, err)
}
if err := m.validateChroot(formats); err != nil {
res = append(res, err)
}
if err := m.validateDaemon(formats); err != nil {
res = append(res, err)
}
if err := m.validateGroup(formats); err != nil {
res = append(res, err)
}
if err := m.validateLogSendHostname(formats); err != nil {
res = append(res, err)
}
if err := m.validateLuaLoads(formats); err != nil {
res = append(res, err)
}
if err := m.validateSslModeAsync(formats); err != nil {
res = append(res, err)
}
if err := m.validateUser(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Global) validateCPUMaps(formats strfmt.Registry) error {
if swag.IsZero(m.CPUMaps) { // not required
return nil
}
for i := 0; i < len(m.CPUMaps); i++ {
if swag.IsZero(m.CPUMaps[i]) { // not required
continue
}
if m.CPUMaps[i] != nil {
if err := m.CPUMaps[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("cpu_maps" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *Global) validateRuntimeAPIs(formats strfmt.Registry) error {
if swag.IsZero(m.RuntimeAPIs) { // not required
return nil
}
for i := 0; i < len(m.RuntimeAPIs); i++ {
if swag.IsZero(m.RuntimeAPIs[i]) { // not required
continue
}
if m.RuntimeAPIs[i] != nil {
if err := m.RuntimeAPIs[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("runtime_apis" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *Global) validateChroot(formats strfmt.Registry) error {
if swag.IsZero(m.Chroot) { // not required
return nil
}
if err := validate.Pattern("chroot", "body", string(m.Chroot), `^[^\s]+$`); err != nil {
return err
}
return nil
}
var globalTypeDaemonPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["enabled","disabled"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
globalTypeDaemonPropEnum = append(globalTypeDaemonPropEnum, v)
}
}
const (
// GlobalDaemonEnabled captures enum value "enabled"
GlobalDaemonEnabled string = "enabled"
// GlobalDaemonDisabled captures enum value "disabled"
GlobalDaemonDisabled string = "disabled"
)
// prop value enum
func (m *Global) validateDaemonEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, globalTypeDaemonPropEnum); err != nil {
return err
}
return nil
}
func (m *Global) validateDaemon(formats strfmt.Registry) error {
if swag.IsZero(m.Daemon) { // not required
return nil
}
// value enum
if err := m.validateDaemonEnum("daemon", "body", m.Daemon); err != nil {
return err
}
return nil
}
func (m *Global) validateGroup(formats strfmt.Registry) error {
if swag.IsZero(m.Group) { // not required
return nil
}
if err := validate.Pattern("group", "body", string(m.Group), `^[^\s]+$`); err != nil {
return err
}
return nil
}
func (m *Global) validateLogSendHostname(formats strfmt.Registry) error {
if swag.IsZero(m.LogSendHostname) { // not required
return nil
}
if m.LogSendHostname != nil {
if err := m.LogSendHostname.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("log_send_hostname")
}
return err
}
}
return nil
}
func (m *Global) validateLuaLoads(formats strfmt.Registry) error {
if swag.IsZero(m.LuaLoads) { // not required
return nil
}
for i := 0; i < len(m.LuaLoads); i++ {
if swag.IsZero(m.LuaLoads[i]) { // not required
continue
}
if m.LuaLoads[i] != nil {
if err := m.LuaLoads[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("lua_loads" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
var globalTypeSslModeAsyncPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["enabled","disabled"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
globalTypeSslModeAsyncPropEnum = append(globalTypeSslModeAsyncPropEnum, v)
}
}
const (
// GlobalSslModeAsyncEnabled captures enum value "enabled"
GlobalSslModeAsyncEnabled string = "enabled"
// GlobalSslModeAsyncDisabled captures enum value "disabled"
GlobalSslModeAsyncDisabled string = "disabled"
)
// prop value enum
func (m *Global) validateSslModeAsyncEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, globalTypeSslModeAsyncPropEnum); err != nil {
return err
}
return nil
}
func (m *Global) validateSslModeAsync(formats strfmt.Registry) error {
if swag.IsZero(m.SslModeAsync) { // not required
return nil
}
// value enum
if err := m.validateSslModeAsyncEnum("ssl_mode_async", "body", m.SslModeAsync); err != nil {
return err
}
return nil
}
func (m *Global) validateUser(formats strfmt.Registry) error {
if swag.IsZero(m.User) { // not required
return nil
}
if err := validate.Pattern("user", "body", string(m.User), `^[^\s]+$`); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *Global) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Global) UnmarshalBinary(b []byte) error {
var res Global
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
// CPUMap CPU map
//
// swagger:model CPUMap
type CPUMap struct {
// cpu set
// Required: true
CPUSet *string `json:"cpu_set"`
// process
// Required: true
Process *string `json:"process"`
}
// Validate validates this CPU map
func (m *CPUMap) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCPUSet(formats); err != nil {
res = append(res, err)
}
if err := m.validateProcess(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *CPUMap) validateCPUSet(formats strfmt.Registry) error {
if err := validate.Required("cpu_set", "body", m.CPUSet); err != nil {
return err
}
return nil
}
func (m *CPUMap) validateProcess(formats strfmt.Registry) error {
if err := validate.Required("process", "body", m.Process); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *CPUMap) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *CPUMap) UnmarshalBinary(b []byte) error {
var res CPUMap
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
// GlobalLogSendHostname global log send hostname
//
// swagger:model GlobalLogSendHostname
type GlobalLogSendHostname struct {
// enabled
// Required: true
// Enum: [enabled disabled]
Enabled *string `json:"enabled"`
// param
// Pattern: ^[^\s]+$
Param string `json:"param,omitempty"`
}
// Validate validates this global log send hostname
func (m *GlobalLogSendHostname) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEnabled(formats); err != nil {
res = append(res, err)
}
if err := m.validateParam(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var globalLogSendHostnameTypeEnabledPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["enabled","disabled"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
globalLogSendHostnameTypeEnabledPropEnum = append(globalLogSendHostnameTypeEnabledPropEnum, v)
}
}
const (
// GlobalLogSendHostnameEnabledEnabled captures enum value "enabled"
GlobalLogSendHostnameEnabledEnabled string = "enabled"
// GlobalLogSendHostnameEnabledDisabled captures enum value "disabled"
GlobalLogSendHostnameEnabledDisabled string = "disabled"
)
// prop value enum
func (m *GlobalLogSendHostname) validateEnabledEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, globalLogSendHostnameTypeEnabledPropEnum); err != nil {
return err
}
return nil
}
func (m *GlobalLogSendHostname) validateEnabled(formats strfmt.Registry) error {
if err := validate.Required("log_send_hostname"+"."+"enabled", "body", m.Enabled); err != nil {
return err
}
// value enum
if err := m.validateEnabledEnum("log_send_hostname"+"."+"enabled", "body", *m.Enabled); err != nil {
return err
}
return nil
}
func (m *GlobalLogSendHostname) validateParam(formats strfmt.Registry) error {
if swag.IsZero(m.Param) { // not required
return nil
}
if err := validate.Pattern("log_send_hostname"+"."+"param", "body", string(m.Param), `^[^\s]+$`); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *GlobalLogSendHostname) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *GlobalLogSendHostname) UnmarshalBinary(b []byte) error {
var res GlobalLogSendHostname
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
// LuaLoad lua load
//
// swagger:model LuaLoad
type LuaLoad struct {
// file
// Required: true
// Pattern: ^[^\s]+$
File *string `json:"file"`
}
// Validate validates this lua load
func (m *LuaLoad) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateFile(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *LuaLoad) validateFile(formats strfmt.Registry) error {
if err := validate.Required("file", "body", m.File); err != nil {
return err
}
if err := validate.Pattern("file", "body", string(*m.File), `^[^\s]+$`); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *LuaLoad) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *LuaLoad) UnmarshalBinary(b []byte) error {
var res LuaLoad
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
// RuntimeAPI runtime API
//
// swagger:model RuntimeAPI
type RuntimeAPI struct {
// address
// Required: true
// Pattern: ^[^\s]+$
Address *string `json:"address"`
// expose fd listeners
ExposeFdListeners bool `json:"exposeFdListeners,omitempty"`
// level
// Enum: [user operator admin]
Level string `json:"level,omitempty"`
// mode
// Pattern: ^[^\s]+$
Mode string `json:"mode,omitempty"`
// process
// Pattern: ^[^\s]+$
Process string `json:"process,omitempty"`
}
// Validate validates this runtime API
func (m *RuntimeAPI) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddress(formats); err != nil {
res = append(res, err)
}
if err := m.validateLevel(formats); err != nil {
res = append(res, err)
}
if err := m.validateMode(formats); err != nil {
res = append(res, err)
}
if err := m.validateProcess(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *RuntimeAPI) validateAddress(formats strfmt.Registry) error {
if err := validate.Required("address", "body", m.Address); err != nil {
return err
}
if err := validate.Pattern("address", "body", string(*m.Address), `^[^\s]+$`); err != nil {
return err
}
return nil
}
var runtimeApiTypeLevelPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["user","operator","admin"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
runtimeApiTypeLevelPropEnum = append(runtimeApiTypeLevelPropEnum, v)
}
}
const (
// RuntimeAPILevelUser captures enum value "user"
RuntimeAPILevelUser string = "user"
// RuntimeAPILevelOperator captures enum value "operator"
RuntimeAPILevelOperator string = "operator"
// RuntimeAPILevelAdmin captures enum value "admin"
RuntimeAPILevelAdmin string = "admin"
)
// prop value enum
func (m *RuntimeAPI) validateLevelEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, runtimeApiTypeLevelPropEnum); err != nil {
return err
}
return nil
}
func (m *RuntimeAPI) validateLevel(formats strfmt.Registry) error {
if swag.IsZero(m.Level) { // not required
return nil
}
// value enum
if err := m.validateLevelEnum("level", "body", m.Level); err != nil {
return err
}
return nil
}
func (m *RuntimeAPI) validateMode(formats strfmt.Registry) error {
if swag.IsZero(m.Mode) { // not required
return nil
}
if err := validate.Pattern("mode", "body", string(m.Mode), `^[^\s]+$`); err != nil {
return err
}
return nil
}
func (m *RuntimeAPI) validateProcess(formats strfmt.Registry) error {
if swag.IsZero(m.Process) { // not required
return nil
}
if err := validate.Pattern("process", "body", string(m.Process), `^[^\s]+$`); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *RuntimeAPI) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *RuntimeAPI) UnmarshalBinary(b []byte) error {
var res RuntimeAPI
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}