/
openstack_cloud_spec.go
237 lines (188 loc) · 7.45 KB
/
openstack_cloud_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
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
// 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 (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// OpenstackCloudSpec OpenstackCloudSpec specifies access data to an OpenStack cloud.
//
// swagger:model OpenstackCloudSpec
type OpenstackCloudSpec struct {
// application credential ID
ApplicationCredentialID string `json:"applicationCredentialID,omitempty"`
// application credential secret
ApplicationCredentialSecret string `json:"applicationCredentialSecret,omitempty"`
// domain
Domain string `json:"domain,omitempty"`
// Enable the `enable-ingress-hostname` cloud provider option on the Openstack CCM. Can only be used with the
// external CCM and might be deprecated and removed in future versions as it is considered a workaround for the PROXY
// protocol to preserve client IPs.
// +optional
EnableIngressHostname bool `json:"enableIngressHostname,omitempty"`
// FloatingIPPool holds the name of the public network
// The public network is reachable from the outside world
// and should provide the pool of IP addresses to choose from.
//
// When specified, all worker nodes will receive a public ip from this floating ip pool
//
// Note that the network is external if the "External" field is set to true
FloatingIPPool string `json:"floatingIPPool,omitempty"`
// IPv6SubnetID holds the ID of the subnet used for IPv6 networking.
// If not provided, a new subnet will be created if IPv6 is enabled.
// +optional
IPV6SubnetID string `json:"ipv6SubnetID,omitempty"`
// IPv6SubnetPool holds the name of the subnet pool used for creating new IPv6 subnets.
// If not provided, the default IPv6 subnet pool will be used.
// +optional
IPV6SubnetPool string `json:"ipv6SubnetPool,omitempty"`
// Set a specific suffix for the hostnames used for the PROXY protocol workaround that is enabled by EnableIngressHostname.
// The suffix is set to `nip.io` by default. Can only be used with the external CCM and might be deprecated and removed in
// future versions as it is considered a workaround only.
IngressHostnameSuffix string `json:"ingressHostnameSuffix,omitempty"`
// Network holds the name of the internal network
// When specified, all worker nodes will be attached to this network. If not specified, a network, subnet & router will be created
//
// Note that the network is internal if the "External" field is set to false
Network string `json:"network,omitempty"`
// A CIDR range that will be used to allow access to the node port range in the security group to. Only applies if
// the security group is generated by KKP and not preexisting.
// If NodePortsAllowedIPRange nor NodePortsAllowedIPRanges is set, the node port range can be accessed from anywhere.
NodePortsAllowedIPRange string `json:"nodePortsAllowedIPRange,omitempty"`
// password
Password string `json:"password,omitempty"`
// project, formally known as tenant.
Project string `json:"project,omitempty"`
// project id, formally known as tenantID.
ProjectID string `json:"projectID,omitempty"`
// router ID
RouterID string `json:"routerID,omitempty"`
// security groups
SecurityGroups string `json:"securityGroups,omitempty"`
// subnet ID
SubnetID string `json:"subnetID,omitempty"`
// Used internally during cluster creation
Token string `json:"token,omitempty"`
// Whether or not to use Octavia for LoadBalancer type of Service
// implementation instead of using Neutron-LBaaS.
// Attention:Openstack CCM use Octavia as default load balancer
// implementation since v1.17.0
//
// Takes precedence over the 'use_octavia' flag provided at datacenter
// level if both are specified.
// +optional
UseOctavia bool `json:"useOctavia,omitempty"`
// use token
UseToken bool `json:"useToken,omitempty"`
// username
Username string `json:"username,omitempty"`
// credentials reference
CredentialsReference *GlobalSecretKeySelector `json:"credentialsReference,omitempty"`
// node ports allowed IP ranges
NodePortsAllowedIPRanges *NetworkRanges `json:"nodePortsAllowedIPRanges,omitempty"`
}
// Validate validates this openstack cloud spec
func (m *OpenstackCloudSpec) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCredentialsReference(formats); err != nil {
res = append(res, err)
}
if err := m.validateNodePortsAllowedIPRanges(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *OpenstackCloudSpec) validateCredentialsReference(formats strfmt.Registry) error {
if swag.IsZero(m.CredentialsReference) { // not required
return nil
}
if m.CredentialsReference != nil {
if err := m.CredentialsReference.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("credentialsReference")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("credentialsReference")
}
return err
}
}
return nil
}
func (m *OpenstackCloudSpec) validateNodePortsAllowedIPRanges(formats strfmt.Registry) error {
if swag.IsZero(m.NodePortsAllowedIPRanges) { // not required
return nil
}
if m.NodePortsAllowedIPRanges != nil {
if err := m.NodePortsAllowedIPRanges.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("nodePortsAllowedIPRanges")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("nodePortsAllowedIPRanges")
}
return err
}
}
return nil
}
// ContextValidate validate this openstack cloud spec based on the context it is used
func (m *OpenstackCloudSpec) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCredentialsReference(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateNodePortsAllowedIPRanges(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *OpenstackCloudSpec) contextValidateCredentialsReference(ctx context.Context, formats strfmt.Registry) error {
if m.CredentialsReference != nil {
if err := m.CredentialsReference.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("credentialsReference")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("credentialsReference")
}
return err
}
}
return nil
}
func (m *OpenstackCloudSpec) contextValidateNodePortsAllowedIPRanges(ctx context.Context, formats strfmt.Registry) error {
if m.NodePortsAllowedIPRanges != nil {
if err := m.NodePortsAllowedIPRanges.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("nodePortsAllowedIPRanges")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("nodePortsAllowedIPRanges")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *OpenstackCloudSpec) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *OpenstackCloudSpec) UnmarshalBinary(b []byte) error {
var res OpenstackCloudSpec
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}