github.com/cilium/cilium@v1.16.2/api/v1/models/l_r_p_backend.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 // LRPBackend Pod backend of an LRP 20 // 21 // swagger:model LRPBackend 22 type LRPBackend struct { 23 24 // backend address 25 BackendAddress *BackendAddress `json:"backend-address,omitempty"` 26 27 // Namespace and name of the backend pod 28 PodID string `json:"pod-id,omitempty"` 29 } 30 31 // Validate validates this l r p backend 32 func (m *LRPBackend) Validate(formats strfmt.Registry) error { 33 var res []error 34 35 if err := m.validateBackendAddress(formats); err != nil { 36 res = append(res, err) 37 } 38 39 if len(res) > 0 { 40 return errors.CompositeValidationError(res...) 41 } 42 return nil 43 } 44 45 func (m *LRPBackend) validateBackendAddress(formats strfmt.Registry) error { 46 if swag.IsZero(m.BackendAddress) { // not required 47 return nil 48 } 49 50 if m.BackendAddress != nil { 51 if err := m.BackendAddress.Validate(formats); err != nil { 52 if ve, ok := err.(*errors.Validation); ok { 53 return ve.ValidateName("backend-address") 54 } else if ce, ok := err.(*errors.CompositeError); ok { 55 return ce.ValidateName("backend-address") 56 } 57 return err 58 } 59 } 60 61 return nil 62 } 63 64 // ContextValidate validate this l r p backend based on the context it is used 65 func (m *LRPBackend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 66 var res []error 67 68 if err := m.contextValidateBackendAddress(ctx, formats); err != nil { 69 res = append(res, err) 70 } 71 72 if len(res) > 0 { 73 return errors.CompositeValidationError(res...) 74 } 75 return nil 76 } 77 78 func (m *LRPBackend) contextValidateBackendAddress(ctx context.Context, formats strfmt.Registry) error { 79 80 if m.BackendAddress != nil { 81 82 if swag.IsZero(m.BackendAddress) { // not required 83 return nil 84 } 85 86 if err := m.BackendAddress.ContextValidate(ctx, formats); err != nil { 87 if ve, ok := err.(*errors.Validation); ok { 88 return ve.ValidateName("backend-address") 89 } else if ce, ok := err.(*errors.CompositeError); ok { 90 return ce.ValidateName("backend-address") 91 } 92 return err 93 } 94 } 95 96 return nil 97 } 98 99 // MarshalBinary interface implementation 100 func (m *LRPBackend) MarshalBinary() ([]byte, error) { 101 if m == nil { 102 return nil, nil 103 } 104 return swag.WriteJSON(m) 105 } 106 107 // UnmarshalBinary interface implementation 108 func (m *LRPBackend) UnmarshalBinary(b []byte) error { 109 var res LRPBackend 110 if err := swag.ReadJSON(b, &res); err != nil { 111 return err 112 } 113 *m = res 114 return nil 115 }