github.com/cilium/cilium@v1.16.2/api/v1/models/wireguard_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 "strconv" 14 15 "github.com/go-openapi/errors" 16 "github.com/go-openapi/strfmt" 17 "github.com/go-openapi/swag" 18 ) 19 20 // WireguardStatus Status of the WireGuard agent 21 // 22 // +k8s:deepcopy-gen=true 23 // 24 // swagger:model WireguardStatus 25 type WireguardStatus struct { 26 27 // WireGuard interfaces managed by this Cilium instance 28 Interfaces []*WireguardInterface `json:"interfaces"` 29 30 // Node Encryption status 31 NodeEncryption string `json:"node-encryption,omitempty"` 32 } 33 34 // Validate validates this wireguard status 35 func (m *WireguardStatus) Validate(formats strfmt.Registry) error { 36 var res []error 37 38 if err := m.validateInterfaces(formats); err != nil { 39 res = append(res, err) 40 } 41 42 if len(res) > 0 { 43 return errors.CompositeValidationError(res...) 44 } 45 return nil 46 } 47 48 func (m *WireguardStatus) validateInterfaces(formats strfmt.Registry) error { 49 if swag.IsZero(m.Interfaces) { // not required 50 return nil 51 } 52 53 for i := 0; i < len(m.Interfaces); i++ { 54 if swag.IsZero(m.Interfaces[i]) { // not required 55 continue 56 } 57 58 if m.Interfaces[i] != nil { 59 if err := m.Interfaces[i].Validate(formats); err != nil { 60 if ve, ok := err.(*errors.Validation); ok { 61 return ve.ValidateName("interfaces" + "." + strconv.Itoa(i)) 62 } else if ce, ok := err.(*errors.CompositeError); ok { 63 return ce.ValidateName("interfaces" + "." + strconv.Itoa(i)) 64 } 65 return err 66 } 67 } 68 69 } 70 71 return nil 72 } 73 74 // ContextValidate validate this wireguard status based on the context it is used 75 func (m *WireguardStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 76 var res []error 77 78 if err := m.contextValidateInterfaces(ctx, formats); err != nil { 79 res = append(res, err) 80 } 81 82 if len(res) > 0 { 83 return errors.CompositeValidationError(res...) 84 } 85 return nil 86 } 87 88 func (m *WireguardStatus) contextValidateInterfaces(ctx context.Context, formats strfmt.Registry) error { 89 90 for i := 0; i < len(m.Interfaces); i++ { 91 92 if m.Interfaces[i] != nil { 93 94 if swag.IsZero(m.Interfaces[i]) { // not required 95 return nil 96 } 97 98 if err := m.Interfaces[i].ContextValidate(ctx, formats); err != nil { 99 if ve, ok := err.(*errors.Validation); ok { 100 return ve.ValidateName("interfaces" + "." + strconv.Itoa(i)) 101 } else if ce, ok := err.(*errors.CompositeError); ok { 102 return ce.ValidateName("interfaces" + "." + strconv.Itoa(i)) 103 } 104 return err 105 } 106 } 107 108 } 109 110 return nil 111 } 112 113 // MarshalBinary interface implementation 114 func (m *WireguardStatus) MarshalBinary() ([]byte, error) { 115 if m == nil { 116 return nil, nil 117 } 118 return swag.WriteJSON(m) 119 } 120 121 // UnmarshalBinary interface implementation 122 func (m *WireguardStatus) UnmarshalBinary(b []byte) error { 123 var res WireguardStatus 124 if err := swag.ReadJSON(b, &res); err != nil { 125 return err 126 } 127 *m = res 128 return nil 129 }