github.com/cilium/cilium@v1.16.2/api/v1/models/node_addressing.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 14 "github.com/go-openapi/errors" 15 "github.com/go-openapi/strfmt" 16 "github.com/go-openapi/swag" 17 ) 18 19 // NodeAddressing Addressing information of a node for all address families 20 // 21 // +k8s:deepcopy-gen=true 22 // 23 // swagger:model NodeAddressing 24 type NodeAddressing struct { 25 26 // ipv4 27 IPV4 *NodeAddressingElement `json:"ipv4,omitempty"` 28 29 // ipv6 30 IPV6 *NodeAddressingElement `json:"ipv6,omitempty"` 31 } 32 33 // Validate validates this node addressing 34 func (m *NodeAddressing) Validate(formats strfmt.Registry) error { 35 var res []error 36 37 if err := m.validateIPV4(formats); err != nil { 38 res = append(res, err) 39 } 40 41 if err := m.validateIPV6(formats); err != nil { 42 res = append(res, err) 43 } 44 45 if len(res) > 0 { 46 return errors.CompositeValidationError(res...) 47 } 48 return nil 49 } 50 51 func (m *NodeAddressing) validateIPV4(formats strfmt.Registry) error { 52 if swag.IsZero(m.IPV4) { // not required 53 return nil 54 } 55 56 if m.IPV4 != nil { 57 if err := m.IPV4.Validate(formats); err != nil { 58 if ve, ok := err.(*errors.Validation); ok { 59 return ve.ValidateName("ipv4") 60 } else if ce, ok := err.(*errors.CompositeError); ok { 61 return ce.ValidateName("ipv4") 62 } 63 return err 64 } 65 } 66 67 return nil 68 } 69 70 func (m *NodeAddressing) validateIPV6(formats strfmt.Registry) error { 71 if swag.IsZero(m.IPV6) { // not required 72 return nil 73 } 74 75 if m.IPV6 != nil { 76 if err := m.IPV6.Validate(formats); err != nil { 77 if ve, ok := err.(*errors.Validation); ok { 78 return ve.ValidateName("ipv6") 79 } else if ce, ok := err.(*errors.CompositeError); ok { 80 return ce.ValidateName("ipv6") 81 } 82 return err 83 } 84 } 85 86 return nil 87 } 88 89 // ContextValidate validate this node addressing based on the context it is used 90 func (m *NodeAddressing) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 91 var res []error 92 93 if err := m.contextValidateIPV4(ctx, formats); err != nil { 94 res = append(res, err) 95 } 96 97 if err := m.contextValidateIPV6(ctx, formats); err != nil { 98 res = append(res, err) 99 } 100 101 if len(res) > 0 { 102 return errors.CompositeValidationError(res...) 103 } 104 return nil 105 } 106 107 func (m *NodeAddressing) contextValidateIPV4(ctx context.Context, formats strfmt.Registry) error { 108 109 if m.IPV4 != nil { 110 111 if swag.IsZero(m.IPV4) { // not required 112 return nil 113 } 114 115 if err := m.IPV4.ContextValidate(ctx, formats); err != nil { 116 if ve, ok := err.(*errors.Validation); ok { 117 return ve.ValidateName("ipv4") 118 } else if ce, ok := err.(*errors.CompositeError); ok { 119 return ce.ValidateName("ipv4") 120 } 121 return err 122 } 123 } 124 125 return nil 126 } 127 128 func (m *NodeAddressing) contextValidateIPV6(ctx context.Context, formats strfmt.Registry) error { 129 130 if m.IPV6 != nil { 131 132 if swag.IsZero(m.IPV6) { // not required 133 return nil 134 } 135 136 if err := m.IPV6.ContextValidate(ctx, formats); err != nil { 137 if ve, ok := err.(*errors.Validation); ok { 138 return ve.ValidateName("ipv6") 139 } else if ce, ok := err.(*errors.CompositeError); ok { 140 return ce.ValidateName("ipv6") 141 } 142 return err 143 } 144 } 145 146 return nil 147 } 148 149 // MarshalBinary interface implementation 150 func (m *NodeAddressing) MarshalBinary() ([]byte, error) { 151 if m == nil { 152 return nil, nil 153 } 154 return swag.WriteJSON(m) 155 } 156 157 // UnmarshalBinary interface implementation 158 func (m *NodeAddressing) UnmarshalBinary(b []byte) error { 159 var res NodeAddressing 160 if err := swag.ReadJSON(b, &res); err != nil { 161 return err 162 } 163 *m = res 164 return nil 165 }