/
seed_spec.go
163 lines (126 loc) · 3.79 KB
/
seed_spec.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
// Code generated by go-swagger; DO NOT EDIT.
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 (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SeedSpec The spec for a seed data
//
// swagger:model SeedSpec
type SeedSpec struct {
// Optional: Country of the seed as ISO-3166 two-letter code, e.g. DE or UK.
// For informational purposes in the Kubermatic dashboard only.
Country string `json:"country,omitempty"`
// Optional: Detailed location of the cluster, like "Hamburg" or "Datacenter 7".
// For informational purposes in the Kubermatic dashboard only.
Location string `json:"location,omitempty"`
// Optional: This can be used to override the DNS name used for this seed.
// By default the seed name is used.
SeedDNSOverwrite string `json:"seed_dns_overwrite,omitempty"`
// Datacenters contains a map of the possible datacenters (DCs) in this seed.
// Each DC must have a globally unique identifier (i.e. names must be unique
// across all seeds).
SeedDatacenters map[string]SeedDatacenter `json:"datacenters,omitempty"`
// expose strategy
ExposeStrategy ServiceType `json:"expose_strategy,omitempty"`
// kubeconfig
Kubeconfig *ObjectReference `json:"kubeconfig,omitempty"`
// proxy settings
ProxySettings *ProxySettings `json:"proxy_settings,omitempty"`
}
// Validate validates this seed spec
func (m *SeedSpec) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateSeedDatacenters(formats); err != nil {
res = append(res, err)
}
if err := m.validateExposeStrategy(formats); err != nil {
res = append(res, err)
}
if err := m.validateKubeconfig(formats); err != nil {
res = append(res, err)
}
if err := m.validateProxySettings(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *SeedSpec) validateSeedDatacenters(formats strfmt.Registry) error {
if swag.IsZero(m.SeedDatacenters) { // not required
return nil
}
for k := range m.SeedDatacenters {
if err := validate.Required("datacenters"+"."+k, "body", m.SeedDatacenters[k]); err != nil {
return err
}
if val, ok := m.SeedDatacenters[k]; ok {
if err := val.Validate(formats); err != nil {
return err
}
}
}
return nil
}
func (m *SeedSpec) validateExposeStrategy(formats strfmt.Registry) error {
if swag.IsZero(m.ExposeStrategy) { // not required
return nil
}
if err := m.ExposeStrategy.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("expose_strategy")
}
return err
}
return nil
}
func (m *SeedSpec) validateKubeconfig(formats strfmt.Registry) error {
if swag.IsZero(m.Kubeconfig) { // not required
return nil
}
if m.Kubeconfig != nil {
if err := m.Kubeconfig.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("kubeconfig")
}
return err
}
}
return nil
}
func (m *SeedSpec) validateProxySettings(formats strfmt.Registry) error {
if swag.IsZero(m.ProxySettings) { // not required
return nil
}
if m.ProxySettings != nil {
if err := m.ProxySettings.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("proxy_settings")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *SeedSpec) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *SeedSpec) UnmarshalBinary(b []byte) error {
var res SeedSpec
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}