github.com/cilium/cilium@v1.16.2/api/v1/models/cluster_mesh_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 // ClusterMeshStatus Status of ClusterMesh 21 // 22 // +k8s:deepcopy-gen=true 23 // 24 // swagger:model ClusterMeshStatus 25 type ClusterMeshStatus struct { 26 27 // List of remote clusters 28 Clusters []*RemoteCluster `json:"clusters"` 29 30 // Number of global services 31 NumGlobalServices int64 `json:"num-global-services,omitempty"` 32 } 33 34 // Validate validates this cluster mesh status 35 func (m *ClusterMeshStatus) Validate(formats strfmt.Registry) error { 36 var res []error 37 38 if err := m.validateClusters(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 *ClusterMeshStatus) validateClusters(formats strfmt.Registry) error { 49 if swag.IsZero(m.Clusters) { // not required 50 return nil 51 } 52 53 for i := 0; i < len(m.Clusters); i++ { 54 if swag.IsZero(m.Clusters[i]) { // not required 55 continue 56 } 57 58 if m.Clusters[i] != nil { 59 if err := m.Clusters[i].Validate(formats); err != nil { 60 if ve, ok := err.(*errors.Validation); ok { 61 return ve.ValidateName("clusters" + "." + strconv.Itoa(i)) 62 } else if ce, ok := err.(*errors.CompositeError); ok { 63 return ce.ValidateName("clusters" + "." + strconv.Itoa(i)) 64 } 65 return err 66 } 67 } 68 69 } 70 71 return nil 72 } 73 74 // ContextValidate validate this cluster mesh status based on the context it is used 75 func (m *ClusterMeshStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 76 var res []error 77 78 if err := m.contextValidateClusters(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 *ClusterMeshStatus) contextValidateClusters(ctx context.Context, formats strfmt.Registry) error { 89 90 for i := 0; i < len(m.Clusters); i++ { 91 92 if m.Clusters[i] != nil { 93 94 if swag.IsZero(m.Clusters[i]) { // not required 95 return nil 96 } 97 98 if err := m.Clusters[i].ContextValidate(ctx, formats); err != nil { 99 if ve, ok := err.(*errors.Validation); ok { 100 return ve.ValidateName("clusters" + "." + strconv.Itoa(i)) 101 } else if ce, ok := err.(*errors.CompositeError); ok { 102 return ce.ValidateName("clusters" + "." + strconv.Itoa(i)) 103 } 104 return err 105 } 106 } 107 108 } 109 110 return nil 111 } 112 113 // MarshalBinary interface implementation 114 func (m *ClusterMeshStatus) 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 *ClusterMeshStatus) UnmarshalBinary(b []byte) error { 123 var res ClusterMeshStatus 124 if err := swag.ReadJSON(b, &res); err != nil { 125 return err 126 } 127 *m = res 128 return nil 129 }