github.com/cilium/cilium@v1.16.2/api/v1/models/name_manager.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 // NameManager Internal state about DNS names in relation to policy subsystem 21 // 22 // swagger:model NameManager 23 type NameManager struct { 24 25 // Names to poll for DNS Poller 26 DNSPollNames []string `json:"DNSPollNames"` 27 28 // Mapping of FQDNSelectors to corresponding regular expressions 29 FQDNPolicySelectors []*SelectorEntry `json:"FQDNPolicySelectors"` 30 } 31 32 // Validate validates this name manager 33 func (m *NameManager) Validate(formats strfmt.Registry) error { 34 var res []error 35 36 if err := m.validateFQDNPolicySelectors(formats); err != nil { 37 res = append(res, err) 38 } 39 40 if len(res) > 0 { 41 return errors.CompositeValidationError(res...) 42 } 43 return nil 44 } 45 46 func (m *NameManager) validateFQDNPolicySelectors(formats strfmt.Registry) error { 47 if swag.IsZero(m.FQDNPolicySelectors) { // not required 48 return nil 49 } 50 51 for i := 0; i < len(m.FQDNPolicySelectors); i++ { 52 if swag.IsZero(m.FQDNPolicySelectors[i]) { // not required 53 continue 54 } 55 56 if m.FQDNPolicySelectors[i] != nil { 57 if err := m.FQDNPolicySelectors[i].Validate(formats); err != nil { 58 if ve, ok := err.(*errors.Validation); ok { 59 return ve.ValidateName("FQDNPolicySelectors" + "." + strconv.Itoa(i)) 60 } else if ce, ok := err.(*errors.CompositeError); ok { 61 return ce.ValidateName("FQDNPolicySelectors" + "." + strconv.Itoa(i)) 62 } 63 return err 64 } 65 } 66 67 } 68 69 return nil 70 } 71 72 // ContextValidate validate this name manager based on the context it is used 73 func (m *NameManager) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 74 var res []error 75 76 if err := m.contextValidateFQDNPolicySelectors(ctx, formats); err != nil { 77 res = append(res, err) 78 } 79 80 if len(res) > 0 { 81 return errors.CompositeValidationError(res...) 82 } 83 return nil 84 } 85 86 func (m *NameManager) contextValidateFQDNPolicySelectors(ctx context.Context, formats strfmt.Registry) error { 87 88 for i := 0; i < len(m.FQDNPolicySelectors); i++ { 89 90 if m.FQDNPolicySelectors[i] != nil { 91 92 if swag.IsZero(m.FQDNPolicySelectors[i]) { // not required 93 return nil 94 } 95 96 if err := m.FQDNPolicySelectors[i].ContextValidate(ctx, formats); err != nil { 97 if ve, ok := err.(*errors.Validation); ok { 98 return ve.ValidateName("FQDNPolicySelectors" + "." + strconv.Itoa(i)) 99 } else if ce, ok := err.(*errors.CompositeError); ok { 100 return ce.ValidateName("FQDNPolicySelectors" + "." + strconv.Itoa(i)) 101 } 102 return err 103 } 104 } 105 106 } 107 108 return nil 109 } 110 111 // MarshalBinary interface implementation 112 func (m *NameManager) MarshalBinary() ([]byte, error) { 113 if m == nil { 114 return nil, nil 115 } 116 return swag.WriteJSON(m) 117 } 118 119 // UnmarshalBinary interface implementation 120 func (m *NameManager) UnmarshalBinary(b []byte) error { 121 var res NameManager 122 if err := swag.ReadJSON(b, &res); err != nil { 123 return err 124 } 125 *m = res 126 return nil 127 }