github.com/cilium/cilium@v1.16.2/api/v1/models/node_element.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright Authors of Cilium 4 // SPDX-License-Identifier: Apache-2.0 5 6 package models 7 8 // This file was generated by the swagger tool. 9 // Editing this file might prove futile when you re-run the swagger generate command 10 11 import ( 12 "context" 13 "strconv" 14 15 "github.com/go-openapi/errors" 16 "github.com/go-openapi/strfmt" 17 "github.com/go-openapi/swag" 18 ) 19 20 // NodeElement Known node in the cluster 21 // 22 // +k8s:deepcopy-gen=true 23 // 24 // swagger:model NodeElement 25 type NodeElement struct { 26 27 // Address used for probing cluster connectivity 28 HealthEndpointAddress *NodeAddressing `json:"health-endpoint-address,omitempty"` 29 30 // Source address for Ingress listener 31 IngressAddress *NodeAddressing `json:"ingress-address,omitempty"` 32 33 // Name of the node including the cluster association. This is typically 34 // <clustername>/<hostname>. 35 // 36 Name string `json:"name,omitempty"` 37 38 // Primary address used for intra-cluster communication 39 PrimaryAddress *NodeAddressing `json:"primary-address,omitempty"` 40 41 // Alternative addresses assigned to the node 42 SecondaryAddresses []*NodeAddressingElement `json:"secondary-addresses"` 43 44 // Source of the node configuration 45 Source string `json:"source,omitempty"` 46 } 47 48 // Validate validates this node element 49 func (m *NodeElement) Validate(formats strfmt.Registry) error { 50 var res []error 51 52 if err := m.validateHealthEndpointAddress(formats); err != nil { 53 res = append(res, err) 54 } 55 56 if err := m.validateIngressAddress(formats); err != nil { 57 res = append(res, err) 58 } 59 60 if err := m.validatePrimaryAddress(formats); err != nil { 61 res = append(res, err) 62 } 63 64 if err := m.validateSecondaryAddresses(formats); err != nil { 65 res = append(res, err) 66 } 67 68 if len(res) > 0 { 69 return errors.CompositeValidationError(res...) 70 } 71 return nil 72 } 73 74 func (m *NodeElement) validateHealthEndpointAddress(formats strfmt.Registry) error { 75 if swag.IsZero(m.HealthEndpointAddress) { // not required 76 return nil 77 } 78 79 if m.HealthEndpointAddress != nil { 80 if err := m.HealthEndpointAddress.Validate(formats); err != nil { 81 if ve, ok := err.(*errors.Validation); ok { 82 return ve.ValidateName("health-endpoint-address") 83 } else if ce, ok := err.(*errors.CompositeError); ok { 84 return ce.ValidateName("health-endpoint-address") 85 } 86 return err 87 } 88 } 89 90 return nil 91 } 92 93 func (m *NodeElement) validateIngressAddress(formats strfmt.Registry) error { 94 if swag.IsZero(m.IngressAddress) { // not required 95 return nil 96 } 97 98 if m.IngressAddress != nil { 99 if err := m.IngressAddress.Validate(formats); err != nil { 100 if ve, ok := err.(*errors.Validation); ok { 101 return ve.ValidateName("ingress-address") 102 } else if ce, ok := err.(*errors.CompositeError); ok { 103 return ce.ValidateName("ingress-address") 104 } 105 return err 106 } 107 } 108 109 return nil 110 } 111 112 func (m *NodeElement) validatePrimaryAddress(formats strfmt.Registry) error { 113 if swag.IsZero(m.PrimaryAddress) { // not required 114 return nil 115 } 116 117 if m.PrimaryAddress != nil { 118 if err := m.PrimaryAddress.Validate(formats); err != nil { 119 if ve, ok := err.(*errors.Validation); ok { 120 return ve.ValidateName("primary-address") 121 } else if ce, ok := err.(*errors.CompositeError); ok { 122 return ce.ValidateName("primary-address") 123 } 124 return err 125 } 126 } 127 128 return nil 129 } 130 131 func (m *NodeElement) validateSecondaryAddresses(formats strfmt.Registry) error { 132 if swag.IsZero(m.SecondaryAddresses) { // not required 133 return nil 134 } 135 136 for i := 0; i < len(m.SecondaryAddresses); i++ { 137 if swag.IsZero(m.SecondaryAddresses[i]) { // not required 138 continue 139 } 140 141 if m.SecondaryAddresses[i] != nil { 142 if err := m.SecondaryAddresses[i].Validate(formats); err != nil { 143 if ve, ok := err.(*errors.Validation); ok { 144 return ve.ValidateName("secondary-addresses" + "." + strconv.Itoa(i)) 145 } else if ce, ok := err.(*errors.CompositeError); ok { 146 return ce.ValidateName("secondary-addresses" + "." + strconv.Itoa(i)) 147 } 148 return err 149 } 150 } 151 152 } 153 154 return nil 155 } 156 157 // ContextValidate validate this node element based on the context it is used 158 func (m *NodeElement) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 159 var res []error 160 161 if err := m.contextValidateHealthEndpointAddress(ctx, formats); err != nil { 162 res = append(res, err) 163 } 164 165 if err := m.contextValidateIngressAddress(ctx, formats); err != nil { 166 res = append(res, err) 167 } 168 169 if err := m.contextValidatePrimaryAddress(ctx, formats); err != nil { 170 res = append(res, err) 171 } 172 173 if err := m.contextValidateSecondaryAddresses(ctx, formats); err != nil { 174 res = append(res, err) 175 } 176 177 if len(res) > 0 { 178 return errors.CompositeValidationError(res...) 179 } 180 return nil 181 } 182 183 func (m *NodeElement) contextValidateHealthEndpointAddress(ctx context.Context, formats strfmt.Registry) error { 184 185 if m.HealthEndpointAddress != nil { 186 187 if swag.IsZero(m.HealthEndpointAddress) { // not required 188 return nil 189 } 190 191 if err := m.HealthEndpointAddress.ContextValidate(ctx, formats); err != nil { 192 if ve, ok := err.(*errors.Validation); ok { 193 return ve.ValidateName("health-endpoint-address") 194 } else if ce, ok := err.(*errors.CompositeError); ok { 195 return ce.ValidateName("health-endpoint-address") 196 } 197 return err 198 } 199 } 200 201 return nil 202 } 203 204 func (m *NodeElement) contextValidateIngressAddress(ctx context.Context, formats strfmt.Registry) error { 205 206 if m.IngressAddress != nil { 207 208 if swag.IsZero(m.IngressAddress) { // not required 209 return nil 210 } 211 212 if err := m.IngressAddress.ContextValidate(ctx, formats); err != nil { 213 if ve, ok := err.(*errors.Validation); ok { 214 return ve.ValidateName("ingress-address") 215 } else if ce, ok := err.(*errors.CompositeError); ok { 216 return ce.ValidateName("ingress-address") 217 } 218 return err 219 } 220 } 221 222 return nil 223 } 224 225 func (m *NodeElement) contextValidatePrimaryAddress(ctx context.Context, formats strfmt.Registry) error { 226 227 if m.PrimaryAddress != nil { 228 229 if swag.IsZero(m.PrimaryAddress) { // not required 230 return nil 231 } 232 233 if err := m.PrimaryAddress.ContextValidate(ctx, formats); err != nil { 234 if ve, ok := err.(*errors.Validation); ok { 235 return ve.ValidateName("primary-address") 236 } else if ce, ok := err.(*errors.CompositeError); ok { 237 return ce.ValidateName("primary-address") 238 } 239 return err 240 } 241 } 242 243 return nil 244 } 245 246 func (m *NodeElement) contextValidateSecondaryAddresses(ctx context.Context, formats strfmt.Registry) error { 247 248 for i := 0; i < len(m.SecondaryAddresses); i++ { 249 250 if m.SecondaryAddresses[i] != nil { 251 252 if swag.IsZero(m.SecondaryAddresses[i]) { // not required 253 return nil 254 } 255 256 if err := m.SecondaryAddresses[i].ContextValidate(ctx, formats); err != nil { 257 if ve, ok := err.(*errors.Validation); ok { 258 return ve.ValidateName("secondary-addresses" + "." + strconv.Itoa(i)) 259 } else if ce, ok := err.(*errors.CompositeError); ok { 260 return ce.ValidateName("secondary-addresses" + "." + strconv.Itoa(i)) 261 } 262 return err 263 } 264 } 265 266 } 267 268 return nil 269 } 270 271 // MarshalBinary interface implementation 272 func (m *NodeElement) MarshalBinary() ([]byte, error) { 273 if m == nil { 274 return nil, nil 275 } 276 return swag.WriteJSON(m) 277 } 278 279 // UnmarshalBinary interface implementation 280 func (m *NodeElement) UnmarshalBinary(b []byte) error { 281 var res NodeElement 282 if err := swag.ReadJSON(b, &res); err != nil { 283 return err 284 } 285 *m = res 286 return nil 287 }