options

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

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"`

	// Pointer because default value of bool is false which could have unintended side effects
	// Check if not nil to ensure it's been set by user
	Credentials *bool `yaml:"credentials,omitempty" json:"credentials,omitempty"`
	MaxAge      int   `yaml:"max_age,omitempty" json:"max_age,omitempty"`
}

func (*CORSOptions) Validate

func (o *CORSOptions) Validate() error

type ClusterOptions

type ClusterOptions struct {
	// ClusterDomain is the base DNS domain for the cluster. Default value is "cluster.local".
	ClusterDomain string `yaml:"cluster_domain,omitempty" json:"cluster_domain,omitempty"`
}

func (*ClusterOptions) Validate

func (o *ClusterOptions) Validate() error

type NGINXIngressOptions

type NGINXIngressOptions struct {
	// RewriteTarget is a custom rewrite target for ingress-nginx.
	// See https://kubernetes.github.io/ingress-nginx/examples/rewrite/ for additional documentation.
	RewriteTarget string `yaml:"rewrite_target,omitempty" json:"rewrite_target,omitempty"`
}

func (*NGINXIngressOptions) Validate

func (o *NGINXIngressOptions) Validate() error

type Options

type Options struct {
	Disabled bool `yaml:"disabled,omitempty" json:"disabled,omitempty"`

	// Namespace for the generated resource. Default value is "default".
	Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`

	// Service is a set of options of a target service to receive traffic.
	Service ServiceOptions `yaml:"service,omitempty" json:"service,omitempty"`

	// Path is a set of options to configure service endpoints paths.
	Path PathOptions `yaml:"path,omitempty" json:"path,omitempty"`

	// Cluster is a set of cluster-wide options.
	Cluster ClusterOptions `yaml:"cluster,omitempty" json:"cluster,omitempty"`

	// Host is an ingress host rule.
	// See https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules for additional documentation.
	Host string `yaml:"host,omitempty" json:"host,omitempty"`

	CORS CORSOptions `yaml:"cors,omitempty" json:"cors,omitempty"`

	// NGINXIngress is a set of custom nginx-ingress options.
	NGINXIngress NGINXIngressOptions `yaml:"nginx_ingress,omitempty" json:"nginx_ingress,omitempty"`

	// PathSubOptions allow to overwrite specific subset of Options for a given path.
	// They are filled during extension parsing, the map key is path.
	PathSubOptions map[string]SubOptions `yaml:"-" json:"-"`

	// OperationSubOptions allow to overwrite specific subset of Options for a given operation.
	// They are filled during extension parsing, the map key is method+path.
	OperationSubOptions map[string]SubOptions `yaml:"-" json:"-"`

	RateLimits RateLimitOptions `yaml:"rate_limits,omitempty" json:"rate_limits,omitempty"`

	Timeouts TimeoutOptions `yaml:"timeouts,omitempty" json:"timeouts,omitempty"`
}

func (*Options) FillDefaultsAndValidate

func (o *Options) FillDefaultsAndValidate() error

func (*Options) GetCORSOpts

func (o *Options) GetCORSOpts(path, method string) CORSOptions

func (*Options) GetRateLimitOpts

func (o *Options) GetRateLimitOpts(path, method string) RateLimitOptions

func (*Options) GetTimeoutOpts

func (o *Options) GetTimeoutOpts(path, method string) TimeoutOptions

func (*Options) IsOperationDisabled

func (o *Options) IsOperationDisabled(path, method string) bool

func (*Options) IsPathDisabled

func (o *Options) IsPathDisabled(path string) bool

func (*Options) Validate

func (o *Options) Validate() error

type PathOptions

type PathOptions struct {
	// Base is the preceding prefix for the route (i.e. /your-prefix/here/rest/of/the/route).
	// Default value is "/".
	Base string `yaml:"base,omitempty" json:"base,omitempty"`

	// TrimPrefix is the prefix that would be omitted from the URL when request is being forwarded
	// to the upstream service, i.e. given that Base is set to "/petstore/api/v3", TrimPrefix is set to "/petstore",
	// path that would be generated is "/petstore/api/v3/pets", URL that the upstream service would receive
	// is "/api/v3/pets".
	TrimPrefix string `yaml:"trim_prefix,omitempty" json:"trim_prefix,omitempty"`

	// Rewrite is the rewrite value that should replace the Base path before being forwarded to the
	// upstream service
	Rewrite string `yaml:"rewrite,omitempty" json:"rewrite,omitempty"`

	// Split forces Kusk to generate a separate resource for each Path or Operation, where appropriate.
	Split bool `yaml:"split,omitempty" json:"split,omitempty"`
}

func (*PathOptions) Validate

func (o *PathOptions) 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) ShouldOverride

func (o *RateLimitOptions) ShouldOverride(opts RateLimitOptions) bool

func (*RateLimitOptions) Validate

func (o *RateLimitOptions) Validate() error

type ServiceOptions

type ServiceOptions struct {
	// Namespace is the namespace containing the upstream Service.
	Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`

	// Name is the upstream Service's name.
	Name string `yaml:"name,omitempty" json:"name,omitempty"`

	// Port is the upstream Service's port. Default value is 80.
	Port int32 `yaml:"port,omitempty" json:"port,omitempty"`
}

func (*ServiceOptions) Validate

func (o *ServiceOptions) Validate() error

type SubOptions

type SubOptions struct {
	Disabled *bool `yaml:"disabled,omitempty" json:"disabled,omitempty"`

	Host       string           `yaml:"host,omitempty" json:"host,omitempty"`
	CORS       CORSOptions      `yaml:"cors,omitempty" json:"cors,omitempty"`
	RateLimits RateLimitOptions `yaml:"rate_limits,omitempty" json:"rate_limits,omitempty"`
	Timeouts   TimeoutOptions   `yaml:"timeouts,omitempty" json:"timeouts,omitempty"`
}

SubOptions allow user to overwrite certain options at path/operation level using x-kusk extension

type TimeoutOptions

type TimeoutOptions struct {
	// 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 (*TimeoutOptions) Validate

func (o *TimeoutOptions) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL