github.com/cilium/cilium@v1.16.2/api/v1/models/named_ports.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 // NamedPorts List of named Layer 4 port and protocol pairs which will be used in Network 21 // Policy specs. 22 // 23 // +deepequal-gen=true 24 // +k8s:deepcopy-gen=true 25 // 26 // swagger:model NamedPorts 27 type NamedPorts []*Port 28 29 // Validate validates this named ports 30 func (m NamedPorts) Validate(formats strfmt.Registry) error { 31 var res []error 32 33 for i := 0; i < len(m); i++ { 34 if swag.IsZero(m[i]) { // not required 35 continue 36 } 37 38 if m[i] != nil { 39 if err := m[i].Validate(formats); err != nil { 40 if ve, ok := err.(*errors.Validation); ok { 41 return ve.ValidateName(strconv.Itoa(i)) 42 } else if ce, ok := err.(*errors.CompositeError); ok { 43 return ce.ValidateName(strconv.Itoa(i)) 44 } 45 return err 46 } 47 } 48 49 } 50 51 if len(res) > 0 { 52 return errors.CompositeValidationError(res...) 53 } 54 return nil 55 } 56 57 // ContextValidate validate this named ports based on the context it is used 58 func (m NamedPorts) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 59 var res []error 60 61 for i := 0; i < len(m); i++ { 62 63 if m[i] != nil { 64 65 if swag.IsZero(m[i]) { // not required 66 return nil 67 } 68 69 if err := m[i].ContextValidate(ctx, formats); err != nil { 70 if ve, ok := err.(*errors.Validation); ok { 71 return ve.ValidateName(strconv.Itoa(i)) 72 } else if ce, ok := err.(*errors.CompositeError); ok { 73 return ce.ValidateName(strconv.Itoa(i)) 74 } 75 return err 76 } 77 } 78 79 } 80 81 if len(res) > 0 { 82 return errors.CompositeValidationError(res...) 83 } 84 return nil 85 }