github.com/cilium/cilium@v1.16.2/api/v1/models/label_configuration_status.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 // LabelConfigurationStatus Labels and label configuration of an endpoint 20 // 21 // swagger:model LabelConfigurationStatus 22 type LabelConfigurationStatus struct { 23 24 // All labels derived from the orchestration system 25 Derived Labels `json:"derived,omitempty"` 26 27 // Labels derived from orchestration system which have been disabled. 28 Disabled Labels `json:"disabled,omitempty"` 29 30 // The current configuration 31 Realized *LabelConfigurationSpec `json:"realized,omitempty"` 32 33 // Labels derived from orchestration system that are used in computing a security identity 34 SecurityRelevant Labels `json:"security-relevant,omitempty"` 35 } 36 37 // Validate validates this label configuration status 38 func (m *LabelConfigurationStatus) Validate(formats strfmt.Registry) error { 39 var res []error 40 41 if err := m.validateDerived(formats); err != nil { 42 res = append(res, err) 43 } 44 45 if err := m.validateDisabled(formats); err != nil { 46 res = append(res, err) 47 } 48 49 if err := m.validateRealized(formats); err != nil { 50 res = append(res, err) 51 } 52 53 if err := m.validateSecurityRelevant(formats); err != nil { 54 res = append(res, err) 55 } 56 57 if len(res) > 0 { 58 return errors.CompositeValidationError(res...) 59 } 60 return nil 61 } 62 63 func (m *LabelConfigurationStatus) validateDerived(formats strfmt.Registry) error { 64 if swag.IsZero(m.Derived) { // not required 65 return nil 66 } 67 68 if err := m.Derived.Validate(formats); err != nil { 69 if ve, ok := err.(*errors.Validation); ok { 70 return ve.ValidateName("derived") 71 } else if ce, ok := err.(*errors.CompositeError); ok { 72 return ce.ValidateName("derived") 73 } 74 return err 75 } 76 77 return nil 78 } 79 80 func (m *LabelConfigurationStatus) validateDisabled(formats strfmt.Registry) error { 81 if swag.IsZero(m.Disabled) { // not required 82 return nil 83 } 84 85 if err := m.Disabled.Validate(formats); err != nil { 86 if ve, ok := err.(*errors.Validation); ok { 87 return ve.ValidateName("disabled") 88 } else if ce, ok := err.(*errors.CompositeError); ok { 89 return ce.ValidateName("disabled") 90 } 91 return err 92 } 93 94 return nil 95 } 96 97 func (m *LabelConfigurationStatus) validateRealized(formats strfmt.Registry) error { 98 if swag.IsZero(m.Realized) { // not required 99 return nil 100 } 101 102 if m.Realized != nil { 103 if err := m.Realized.Validate(formats); err != nil { 104 if ve, ok := err.(*errors.Validation); ok { 105 return ve.ValidateName("realized") 106 } else if ce, ok := err.(*errors.CompositeError); ok { 107 return ce.ValidateName("realized") 108 } 109 return err 110 } 111 } 112 113 return nil 114 } 115 116 func (m *LabelConfigurationStatus) validateSecurityRelevant(formats strfmt.Registry) error { 117 if swag.IsZero(m.SecurityRelevant) { // not required 118 return nil 119 } 120 121 if err := m.SecurityRelevant.Validate(formats); err != nil { 122 if ve, ok := err.(*errors.Validation); ok { 123 return ve.ValidateName("security-relevant") 124 } else if ce, ok := err.(*errors.CompositeError); ok { 125 return ce.ValidateName("security-relevant") 126 } 127 return err 128 } 129 130 return nil 131 } 132 133 // ContextValidate validate this label configuration status based on the context it is used 134 func (m *LabelConfigurationStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 135 var res []error 136 137 if err := m.contextValidateDerived(ctx, formats); err != nil { 138 res = append(res, err) 139 } 140 141 if err := m.contextValidateDisabled(ctx, formats); err != nil { 142 res = append(res, err) 143 } 144 145 if err := m.contextValidateRealized(ctx, formats); err != nil { 146 res = append(res, err) 147 } 148 149 if err := m.contextValidateSecurityRelevant(ctx, formats); err != nil { 150 res = append(res, err) 151 } 152 153 if len(res) > 0 { 154 return errors.CompositeValidationError(res...) 155 } 156 return nil 157 } 158 159 func (m *LabelConfigurationStatus) contextValidateDerived(ctx context.Context, formats strfmt.Registry) error { 160 161 if err := m.Derived.ContextValidate(ctx, formats); err != nil { 162 if ve, ok := err.(*errors.Validation); ok { 163 return ve.ValidateName("derived") 164 } else if ce, ok := err.(*errors.CompositeError); ok { 165 return ce.ValidateName("derived") 166 } 167 return err 168 } 169 170 return nil 171 } 172 173 func (m *LabelConfigurationStatus) contextValidateDisabled(ctx context.Context, formats strfmt.Registry) error { 174 175 if err := m.Disabled.ContextValidate(ctx, formats); err != nil { 176 if ve, ok := err.(*errors.Validation); ok { 177 return ve.ValidateName("disabled") 178 } else if ce, ok := err.(*errors.CompositeError); ok { 179 return ce.ValidateName("disabled") 180 } 181 return err 182 } 183 184 return nil 185 } 186 187 func (m *LabelConfigurationStatus) contextValidateRealized(ctx context.Context, formats strfmt.Registry) error { 188 189 if m.Realized != nil { 190 191 if swag.IsZero(m.Realized) { // not required 192 return nil 193 } 194 195 if err := m.Realized.ContextValidate(ctx, formats); err != nil { 196 if ve, ok := err.(*errors.Validation); ok { 197 return ve.ValidateName("realized") 198 } else if ce, ok := err.(*errors.CompositeError); ok { 199 return ce.ValidateName("realized") 200 } 201 return err 202 } 203 } 204 205 return nil 206 } 207 208 func (m *LabelConfigurationStatus) contextValidateSecurityRelevant(ctx context.Context, formats strfmt.Registry) error { 209 210 if err := m.SecurityRelevant.ContextValidate(ctx, formats); err != nil { 211 if ve, ok := err.(*errors.Validation); ok { 212 return ve.ValidateName("security-relevant") 213 } else if ce, ok := err.(*errors.CompositeError); ok { 214 return ce.ValidateName("security-relevant") 215 } 216 return err 217 } 218 219 return nil 220 } 221 222 // MarshalBinary interface implementation 223 func (m *LabelConfigurationStatus) MarshalBinary() ([]byte, error) { 224 if m == nil { 225 return nil, nil 226 } 227 return swag.WriteJSON(m) 228 } 229 230 // UnmarshalBinary interface implementation 231 func (m *LabelConfigurationStatus) UnmarshalBinary(b []byte) error { 232 var res LabelConfigurationStatus 233 if err := swag.ReadJSON(b, &res); err != nil { 234 return err 235 } 236 *m = res 237 return nil 238 }