Documentation
¶
Index ¶
- Constants
- type CORSOptions
- type HTTPMethod
- type Host
- type MockingOptions
- type Options
- type PathOptions
- type QoSOptions
- type RateLimitOptions
- type RedirectOptions
- type RequestValidationOptions
- type RewriteRegex
- type StaticOperationSubOptions
- type StaticOptions
- type SubOptions
- type UpstreamHost
- type UpstreamOptions
- type UpstreamService
- type ValidationOptions
Constants ¶
const MaxRetries uint32 = 255
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CORSOptions ¶
type CORSOptions struct { Origins []string `yaml:"origins,omitempty" json:"origins,omitempty"` Methods []string `yaml:"methods,omitempty" json:"methods,omitempty"` Headers []string `yaml:"headers,omitempty" json:"headers,omitempty"` ExposeHeaders []string `yaml:"expose_headers,omitempty" json:"expose_headers,omitempty"` Credentials *bool `yaml:"credentials,omitempty" json:"credentials,omitempty"` MaxAge int `yaml:"max_age,omitempty" json:"max_age,omitempty"` }
func (*CORSOptions) DeepCopy ¶
func (in *CORSOptions) DeepCopy() *CORSOptions
DeepCopy creates a copy of an object
func (CORSOptions) Validate ¶
func (o CORSOptions) Validate() error
type Host ¶
type Host string
Host is a vHost (and domain name) definition that is used during request routing. Could be wildcard ("*" - all vhosts), prefix/suffix wildcard (*-example.com, example.*, but not both *example*), or simple domain (www.example.com)
type MockingOptions ¶
type MockingOptions struct {
Enabled *bool `json:"enabled" yaml:"mocking"`
}
func (MockingOptions) Validate ¶
func (o MockingOptions) Validate() error
type Options ¶
type Options struct { // Top root of the configuration (top x-kusk settings) provides configuration for all paths/methods // Overrides per method+path are in OperationFinalSubOptions map SubOptions // Host (Host header) to serve for // Multiple are possible // Hosts are not overridable per path/method intentionally since // there is no valid use case for such override per path in the same OpenAPI config Hosts []Host `yaml:"hosts,omitempty" json:"hosts,omitempty"` // OperationFinalSubOptions is the map of method+path key with value - merged root suboptions + path suboptions + operation suboptions // They are filled during the parsing of OpenAPI with extension OperationFinalSubOptions map[string]SubOptions `yaml:"-" json:"-"` }
Options is the container for all parsed from the supplied configuration OpenAPI x-kusk options and any additional options
func (*Options) FillDefaults ¶
func (o *Options) FillDefaults()
type PathOptions ¶
type PathOptions struct { // Prefix is the preceding prefix for the route (i.e. /your-prefix/here/rest/of/the/route). Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"` }
func (PathOptions) Validate ¶
func (o PathOptions) Validate() error
type QoSOptions ¶
type QoSOptions struct { // Retries define how many times to retry calling the backend Retries uint32 `yaml:"retries,omitempty" json:"retries,omitempty"` // RequestTimeout is total request timeout RequestTimeout uint32 `yaml:"request_timeout,omitempty" json:"request_timeout,omitempty"` // IdleTimeout is timeout for idle connection IdleTimeout uint32 `yaml:"idle_timeout,omitempty" json:"idle_timeout,omitempty"` }
func (QoSOptions) Validate ¶
func (o QoSOptions) Validate() error
type RateLimitOptions ¶
type RateLimitOptions struct { RPS uint32 `json:"rps,omitempty" yaml:"rps,omitempty"` Burst uint32 `json:"burst,omitempty" yaml:"burst,omitempty"` Group string `json:"group,omitempty" yaml:"group,omitempty"` }
func (RateLimitOptions) Validate ¶
func (o RateLimitOptions) Validate() error
type RedirectOptions ¶
type RedirectOptions struct { // http|https SchemeRedirect string `yaml:"scheme_redirect,omitempty" json:"scheme_redirect,omitempty"` HostRedirect string `yaml:"host_redirect,omitempty" json:"host_redirect,omitempty"` PortRedirect uint32 `yaml:"port_redirect,omitempty" json:"port_redirect,omitempty"` // mutually exclusive with rewrite regex redirect PathRedirect string `yaml:"path_redirect,omitempty" json:"path_redirect,omitempty"` // mutually exclusive with path redirect RewriteRegex *RewriteRegex `yaml:"rewrite_regex,omitempty" json:"rewrite_regex,omitempty"` ResponseCode uint32 `yaml:"response_code,omitempty" json:"response_code,omitempty"` StripQuery *bool `yaml:"strip_query,omitempty" json:"strip_query,omitempty"` }
RedirectOptions provide http redirects see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-redirectaction
func (*RedirectOptions) DeepCopy ¶
func (in *RedirectOptions) DeepCopy() *RedirectOptions
DeepCopy is used to copy
func (RedirectOptions) MutuallyExlusivePathRedirectCheck ¶
func (o RedirectOptions) MutuallyExlusivePathRedirectCheck(value interface{}) error
MutuallyExclusivePathRedirectCheck returns error if both path redirect and regex substitution redirect are enabled
func (RedirectOptions) Validate ¶
func (o RedirectOptions) Validate() error
type RequestValidationOptions ¶
type RequestValidationOptions struct {
Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
}
type RewriteRegex ¶
type RewriteRegex struct { Pattern string `yaml:"pattern,omitempty" json:"pattern"` Substitution string `yaml:"substitution,omitempty" json:"substitution"` }
RewriteRegex is used during the redirects and paths mangling
func (RewriteRegex) Validate ¶
func (r RewriteRegex) Validate() error
type StaticOperationSubOptions ¶
type StaticOperationSubOptions map[HTTPMethod]*SubOptions
StaticOperationSubOptions maps method (get, post) to related static subopts
type StaticOptions ¶
type StaticOptions struct { // Host (Host header) to serve for. // Multiple are possible. Each Host creates Envoy's Virtual Host with Domains set to only that Host and routes specified in config. // I.e. multiple hosts - multiple vHosts with Domains=Host and with the same routes. // Note on Host header matching in Envoy: /* courtesy of @hzxuzhonghu (https://github.com/istio/istio/issues/35826#issuecomment-957184380) The virtual hosts order does not influence the domain matching order It is the domain matters Domain search order: 1. Exact domain names: www.foo.com. 2. Suffix domain wildcards: *.foo.com or *-bar.foo.com. 3. Prefix domain wildcards: foo.* or foo-*. 4. Special wildcard * matching any domain. (edited) */ Hosts []Host // Paths allow to specify a specific set of option for a given path and a method. // This is a 2-dimensional map[path][method]. // The map key is the path and the next map key is a HTTP method (operation). // This closely follows OpenAPI structure, but was chosen only due to the only way to specify different routing action for // different methods in one YAML document. // E.g. if GET / goes to frontend, and POST / goes to API, you cannot specify path as a key with the different methods twice in one YAML file. Paths map[string]StaticOperationSubOptions `yaml:"-" json:"-"` }
StaticOptions define options for single routing config - domain names to use and path to setup routes for.
func (*StaticOptions) FillDefaultsAndValidate ¶
func (o *StaticOptions) FillDefaultsAndValidate() error
func (StaticOptions) Validate ¶
func (o StaticOptions) Validate() error
type SubOptions ¶
type SubOptions struct { Disabled *bool `yaml:"disabled,omitempty" json:"disabled,omitempty"` // Upstream is a set of options of a target service to receive traffic. Upstream *UpstreamOptions `yaml:"upstream,omitempty" json:"upstream,omitempty"` // Redirect specifies thre redirect optins, mutually exclusive with Upstream Redirect *RedirectOptions `yaml:"redirect,omitempty" json:"redirect,omitempty"` // Path is a set of options to configure service endpoints paths. Path *PathOptions `yaml:"path,omitempty" json:"path,omitempty"` QoS *QoSOptions `yaml:"qos,omitempty" json:"qos,omitempty"` CORS *CORSOptions `yaml:"cors,omitempty" json:"cors,omitempty"` Websocket *bool `json:"websocket,omitempty" yaml:"websocket,omitempty"` Validation *ValidationOptions `json:"validation,omitempty" yaml:"validation,omitempty"` Mocking *MockingOptions `json:"mocking,omitempty" yaml:"mocking,omitempty"` }
SubOptions allow user to overwrite certain options at path/operation level using x-kusk extension
func (*SubOptions) MergeInSubOptions ¶
func (o *SubOptions) MergeInSubOptions(in *SubOptions)
MergeInSubOptions handles merging other SubOptions (usually - upper level in root/path/method hierarchy)
func (SubOptions) Validate ¶
func (o SubOptions) Validate() error
type UpstreamHost ¶
type UpstreamHost struct { // Hostname is the upstream hostname, without port. Hostname string `yaml:"hostname" json:"hostname"` // Port is the upstream port. Port uint32 `yaml:"port" json:"port"` }
UpstreamHost defines any DNS hostname with port that we can proxy to, even outside of the cluster
func (UpstreamHost) Validate ¶
func (o UpstreamHost) Validate() error
type UpstreamOptions ¶
type UpstreamOptions struct { Host *UpstreamHost `yaml:"host,omitempty" json:"host,omitempty"` Service *UpstreamService `yaml:"service,omitempty" json:"service,omitempty"` // Rewrite is the pattern (regex) and a substitution string that will change URL when request is being forwarded // to the upstream service. // e.g. given that Prefix is set to "/petstore/api/v3", and with // Rewrite.Pattern is set to "^/petstore", Rewrite.Substitution is set to "" // path that would be generated is "/petstore/api/v3/pets", URL that the upstream service would receive // is "/api/v3/pets". Rewrite RewriteRegex `yaml:"rewrite,omitempty" json:"rewrite,omitempty"` }
UpstreamOptions defines upstream that we proxy to Host and Service are mutually exclusive
func (*UpstreamOptions) DeepCopy ¶
func (in *UpstreamOptions) DeepCopy() *UpstreamOptions
DeepCopy creates a copy of an object
func (UpstreamOptions) Validate ¶
func (o UpstreamOptions) Validate() error
type UpstreamService ¶
type UpstreamService struct { // Name is the upstream K8s Service's name. Name string `yaml:"name" json:"name,omitempty"` // Namespace where service is located Namespace string `yaml:"namespace" json:"namespace"` // Port is the upstream K8s Service's port. Port uint32 `yaml:"port" json:"port"` }
UpstreamService defines K8s Service in the cluster
func (UpstreamService) Validate ¶
func (o UpstreamService) Validate() error
type ValidationOptions ¶
type ValidationOptions struct {
Request *RequestValidationOptions `json:"request,omitempty" yaml:"request,omitempty"`
}