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