github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/registry_provider_endpoint_pattern.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 "strconv" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 ) 16 17 // RegistryProviderEndpointPattern The registry endpoint pattern 18 // 19 // swagger:model RegistryProviderEndpointPattern 20 type RegistryProviderEndpointPattern struct { 21 22 // The endpoint type 23 EndpointType string `json:"endpoint_type,omitempty"` 24 25 // The endpoint list 26 Endpoints []*RegistryEndpoint `json:"endpoints"` 27 } 28 29 // Validate validates this registry provider endpoint pattern 30 func (m *RegistryProviderEndpointPattern) Validate(formats strfmt.Registry) error { 31 var res []error 32 33 if err := m.validateEndpoints(formats); err != nil { 34 res = append(res, err) 35 } 36 37 if len(res) > 0 { 38 return errors.CompositeValidationError(res...) 39 } 40 return nil 41 } 42 43 func (m *RegistryProviderEndpointPattern) validateEndpoints(formats strfmt.Registry) error { 44 if swag.IsZero(m.Endpoints) { // not required 45 return nil 46 } 47 48 for i := 0; i < len(m.Endpoints); i++ { 49 if swag.IsZero(m.Endpoints[i]) { // not required 50 continue 51 } 52 53 if m.Endpoints[i] != nil { 54 if err := m.Endpoints[i].Validate(formats); err != nil { 55 if ve, ok := err.(*errors.Validation); ok { 56 return ve.ValidateName("endpoints" + "." + strconv.Itoa(i)) 57 } else if ce, ok := err.(*errors.CompositeError); ok { 58 return ce.ValidateName("endpoints" + "." + strconv.Itoa(i)) 59 } 60 return err 61 } 62 } 63 64 } 65 66 return nil 67 } 68 69 // ContextValidate validate this registry provider endpoint pattern based on the context it is used 70 func (m *RegistryProviderEndpointPattern) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 71 var res []error 72 73 if err := m.contextValidateEndpoints(ctx, formats); err != nil { 74 res = append(res, err) 75 } 76 77 if len(res) > 0 { 78 return errors.CompositeValidationError(res...) 79 } 80 return nil 81 } 82 83 func (m *RegistryProviderEndpointPattern) contextValidateEndpoints(ctx context.Context, formats strfmt.Registry) error { 84 85 for i := 0; i < len(m.Endpoints); i++ { 86 87 if m.Endpoints[i] != nil { 88 if err := m.Endpoints[i].ContextValidate(ctx, formats); err != nil { 89 if ve, ok := err.(*errors.Validation); ok { 90 return ve.ValidateName("endpoints" + "." + strconv.Itoa(i)) 91 } else if ce, ok := err.(*errors.CompositeError); ok { 92 return ce.ValidateName("endpoints" + "." + strconv.Itoa(i)) 93 } 94 return err 95 } 96 } 97 98 } 99 100 return nil 101 } 102 103 // MarshalBinary interface implementation 104 func (m *RegistryProviderEndpointPattern) MarshalBinary() ([]byte, error) { 105 if m == nil { 106 return nil, nil 107 } 108 return swag.WriteJSON(m) 109 } 110 111 // UnmarshalBinary interface implementation 112 func (m *RegistryProviderEndpointPattern) UnmarshalBinary(b []byte) error { 113 var res RegistryProviderEndpointPattern 114 if err := swag.ReadJSON(b, &res); err != nil { 115 return err 116 } 117 *m = res 118 return nil 119 }