github.com/cilium/cilium@v1.16.2/api/v1/models/proxy_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 "encoding/json" 14 "strconv" 15 16 "github.com/go-openapi/errors" 17 "github.com/go-openapi/strfmt" 18 "github.com/go-openapi/swag" 19 "github.com/go-openapi/validate" 20 ) 21 22 // ProxyStatus Status of proxy 23 // 24 // +k8s:deepcopy-gen=true 25 // 26 // swagger:model ProxyStatus 27 type ProxyStatus struct { 28 29 // Deployment mode of Envoy L7 proxy 30 // Enum: [embedded external] 31 EnvoyDeploymentMode string `json:"envoy-deployment-mode,omitempty"` 32 33 // IP address that the proxy listens on 34 IP string `json:"ip,omitempty"` 35 36 // Port range used for proxying 37 PortRange string `json:"port-range,omitempty"` 38 39 // Detailed description of configured redirects 40 Redirects []*ProxyRedirect `json:"redirects"` 41 42 // Total number of listening proxy ports 43 TotalPorts int64 `json:"total-ports,omitempty"` 44 45 // Total number of ports configured to redirect to proxies 46 TotalRedirects int64 `json:"total-redirects,omitempty"` 47 } 48 49 // Validate validates this proxy status 50 func (m *ProxyStatus) Validate(formats strfmt.Registry) error { 51 var res []error 52 53 if err := m.validateEnvoyDeploymentMode(formats); err != nil { 54 res = append(res, err) 55 } 56 57 if err := m.validateRedirects(formats); err != nil { 58 res = append(res, err) 59 } 60 61 if len(res) > 0 { 62 return errors.CompositeValidationError(res...) 63 } 64 return nil 65 } 66 67 var proxyStatusTypeEnvoyDeploymentModePropEnum []interface{} 68 69 func init() { 70 var res []string 71 if err := json.Unmarshal([]byte(`["embedded","external"]`), &res); err != nil { 72 panic(err) 73 } 74 for _, v := range res { 75 proxyStatusTypeEnvoyDeploymentModePropEnum = append(proxyStatusTypeEnvoyDeploymentModePropEnum, v) 76 } 77 } 78 79 const ( 80 81 // ProxyStatusEnvoyDeploymentModeEmbedded captures enum value "embedded" 82 ProxyStatusEnvoyDeploymentModeEmbedded string = "embedded" 83 84 // ProxyStatusEnvoyDeploymentModeExternal captures enum value "external" 85 ProxyStatusEnvoyDeploymentModeExternal string = "external" 86 ) 87 88 // prop value enum 89 func (m *ProxyStatus) validateEnvoyDeploymentModeEnum(path, location string, value string) error { 90 if err := validate.EnumCase(path, location, value, proxyStatusTypeEnvoyDeploymentModePropEnum, true); err != nil { 91 return err 92 } 93 return nil 94 } 95 96 func (m *ProxyStatus) validateEnvoyDeploymentMode(formats strfmt.Registry) error { 97 if swag.IsZero(m.EnvoyDeploymentMode) { // not required 98 return nil 99 } 100 101 // value enum 102 if err := m.validateEnvoyDeploymentModeEnum("envoy-deployment-mode", "body", m.EnvoyDeploymentMode); err != nil { 103 return err 104 } 105 106 return nil 107 } 108 109 func (m *ProxyStatus) validateRedirects(formats strfmt.Registry) error { 110 if swag.IsZero(m.Redirects) { // not required 111 return nil 112 } 113 114 for i := 0; i < len(m.Redirects); i++ { 115 if swag.IsZero(m.Redirects[i]) { // not required 116 continue 117 } 118 119 if m.Redirects[i] != nil { 120 if err := m.Redirects[i].Validate(formats); err != nil { 121 if ve, ok := err.(*errors.Validation); ok { 122 return ve.ValidateName("redirects" + "." + strconv.Itoa(i)) 123 } else if ce, ok := err.(*errors.CompositeError); ok { 124 return ce.ValidateName("redirects" + "." + strconv.Itoa(i)) 125 } 126 return err 127 } 128 } 129 130 } 131 132 return nil 133 } 134 135 // ContextValidate validate this proxy status based on the context it is used 136 func (m *ProxyStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 137 var res []error 138 139 if err := m.contextValidateRedirects(ctx, formats); err != nil { 140 res = append(res, err) 141 } 142 143 if len(res) > 0 { 144 return errors.CompositeValidationError(res...) 145 } 146 return nil 147 } 148 149 func (m *ProxyStatus) contextValidateRedirects(ctx context.Context, formats strfmt.Registry) error { 150 151 for i := 0; i < len(m.Redirects); i++ { 152 153 if m.Redirects[i] != nil { 154 155 if swag.IsZero(m.Redirects[i]) { // not required 156 return nil 157 } 158 159 if err := m.Redirects[i].ContextValidate(ctx, formats); err != nil { 160 if ve, ok := err.(*errors.Validation); ok { 161 return ve.ValidateName("redirects" + "." + strconv.Itoa(i)) 162 } else if ce, ok := err.(*errors.CompositeError); ok { 163 return ce.ValidateName("redirects" + "." + strconv.Itoa(i)) 164 } 165 return err 166 } 167 } 168 169 } 170 171 return nil 172 } 173 174 // MarshalBinary interface implementation 175 func (m *ProxyStatus) MarshalBinary() ([]byte, error) { 176 if m == nil { 177 return nil, nil 178 } 179 return swag.WriteJSON(m) 180 } 181 182 // UnmarshalBinary interface implementation 183 func (m *ProxyStatus) UnmarshalBinary(b []byte) error { 184 var res ProxyStatus 185 if err := swag.ReadJSON(b, &res); err != nil { 186 return err 187 } 188 *m = res 189 return nil 190 }