rules

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGet     = Method(http.MethodGet)
	MethodHead    = Method(http.MethodHead)
	MethodPost    = Method(http.MethodPost)
	MethodPut     = Method(http.MethodPut)
	MethodPatch   = Method(http.MethodPatch)
	MethodDelete  = Method(http.MethodDelete)
	MethodConnect = Method(http.MethodConnect)
	MethodOptions = Method(http.MethodOptions)
	MethodTrace   = Method(http.MethodTrace)
)

Variables

View Source
var (
	ErrIllegalMethod = errors.New("illegal method")

	AllMethods = Methods{
		MethodGet,
		MethodHead,
		MethodPost,
		MethodPut,
		MethodPatch,
		MethodDelete,
		MethodConnect,
		MethodOptions,
		MethodTrace,
	}
)
View Source
var (
	ErrIllegalPath = errors.New("illegal path")
)

Functions

func AnnotationIsForcibleBool added in v0.4.0

func AnnotationIsForcibleBool(name, v string) (result value.ForcibleBool, err error)

func AnnotationIsTrue added in v0.1.6

func AnnotationIsTrue(name, v string) (value.Bool, error)

func ParsePath

func ParsePath(in string, faultTolerant bool) ([]string, error)

Types

type Address

type Address interface {
	Matches(net.IP) bool
}

func AnnotationAddresses added in v0.1.6

func AnnotationAddresses(name, value string) (result []Address, err error)

type Annotations added in v0.1.6

type Annotations map[string]string

type ByHost

type ByHost struct {
	// contains filtered or unexported fields
}

func NewByHost

func NewByHost(onAdded OnAdded, onRemoved OnRemoved) *ByHost

func (*ByHost) All

func (instance *ByHost) All(consumer func(Rule) error) error

func (*ByHost) Clone

func (instance *ByHost) Clone() *ByHost

func (*ByHost) Find

func (instance *ByHost) Find(host value.Fqdn, path []string) (Rules, error)

func (*ByHost) Put

func (instance *ByHost) Put(r Rule) error

func (*ByHost) Remove

func (instance *ByHost) Remove(predicate Predicate) error

type ByPath

type ByPath struct {
	// contains filtered or unexported fields
}

func NewByPath

func NewByPath(onAdded OnAdded, onRemoved OnRemoved) *ByPath

func (*ByPath) All

func (instance *ByPath) All(consumer func(Rule) error) error

func (*ByPath) Clone

func (instance *ByPath) Clone() *ByPath

func (*ByPath) Find

func (instance *ByPath) Find(path []string) (Rules, error)

func (*ByPath) HasContent

func (instance *ByPath) HasContent() bool

func (*ByPath) Put

func (instance *ByPath) Put(r Rule) error

func (*ByPath) Remove

func (instance *ByPath) Remove(predicate Predicate) error

type CertificateQuery

type CertificateQuery struct {
	Host string
}

type CertificateRepository

type CertificateRepository interface {
	FindCertificatesBy(CertificateQuery) (Certificates, error)
}

type Certificates

type Certificates []*tls.Certificate

type CertificatesByHost

type CertificatesByHost struct {
	// contains filtered or unexported fields
}

func (*CertificatesByHost) Add

func (instance *CertificatesByHost) Add(certificate tls.Certificate) error

func (*CertificatesByHost) AddBytes

func (instance *CertificatesByHost) AddBytes(certificate, privateKey []byte) error

func (CertificatesByHost) Find

func (instance CertificatesByHost) Find(host string) Certificates

type CombinedRepository

type CombinedRepository interface {
	Repository
	CertificateRepository
}

func NewRepository

func NewRepository() (CombinedRepository, error)

type ForcibleHeaderNames added in v0.4.0

type ForcibleHeaderNames struct {
	value.Forcible
}

func NewForcibleHeaders added in v0.4.0

func NewForcibleHeaders(init HeaderNames, forced bool) ForcibleHeaderNames

func (ForcibleHeaderNames) Evaluate added in v0.4.0

func (instance ForcibleHeaderNames) Evaluate(other HeaderNames, def HeaderNames) HeaderNames

type ForcibleHostPatterns added in v0.4.0

type ForcibleHostPatterns struct {
	value.Forcible
}

func NewForcibleHostPatterns added in v0.4.0

func NewForcibleHostPatterns(init HostPatterns, forced bool) ForcibleHostPatterns

func (ForcibleHostPatterns) Evaluate added in v0.4.0

func (instance ForcibleHostPatterns) Evaluate(other HostPatterns, def HostPatterns) HostPatterns

type ForcibleMethods added in v0.4.0

type ForcibleMethods struct {
	value.Forcible
}

func NewForcibleMethods added in v0.4.0

func NewForcibleMethods(init Methods, forced bool) ForcibleMethods

func (ForcibleMethods) Evaluate added in v0.4.0

func (instance ForcibleMethods) Evaluate(other Methods, def Methods) Methods
type Header struct {
	Key    string
	Value  string
	Forced bool
	Add    bool
	Del    bool
}

func (*Header) Set

func (instance *Header) Set(plain string) error

func (Header) String

func (instance Header) String() string

type HeaderName added in v0.1.22

type HeaderName string

func ParseHeaderName added in v0.1.22

func ParseHeaderName(plain string) (result HeaderName, err error)

func (*HeaderName) Set added in v0.1.22

func (instance *HeaderName) Set(plain string) error

func (HeaderName) String added in v0.1.22

func (instance HeaderName) String() string

type HeaderNames added in v0.1.22

type HeaderNames []HeaderName

func ParseHeaderNames added in v0.1.22

func ParseHeaderNames(plain string) (result HeaderNames, err error)

func (HeaderNames) Get added in v0.1.22

func (instance HeaderNames) Get() interface{}

func (HeaderNames) IsPresent added in v0.1.22

func (instance HeaderNames) IsPresent() bool

func (HeaderNames) Matches added in v0.1.22

func (instance HeaderNames) Matches(test HeaderName) bool

func (*HeaderNames) Set added in v0.1.22

func (instance *HeaderNames) Set(plain string) error

func (HeaderNames) String added in v0.1.22

func (instance HeaderNames) String() string

type Headers

type Headers []Header

func (*Headers) IsCumulative

func (instance *Headers) IsCumulative() bool

func (*Headers) Set

func (instance *Headers) Set(plain string) error

func (Headers) String

func (instance Headers) String() string

type HostPattern added in v0.1.22

type HostPattern []string

func ParseHostPattern added in v0.1.22

func ParseHostPattern(plain string) (result HostPattern, err error)

func (HostPattern) Matches added in v0.1.22

func (instance HostPattern) Matches(test string) bool

func (*HostPattern) Set added in v0.1.22

func (instance *HostPattern) Set(plain string) error

func (HostPattern) String added in v0.1.22

func (instance HostPattern) String() string

type HostPatterns added in v0.1.22

type HostPatterns []HostPattern

func ParseHostPatterns added in v0.1.22

func ParseHostPatterns(plain string) (result HostPatterns, err error)

func (HostPatterns) Get added in v0.1.22

func (instance HostPatterns) Get() interface{}

func (HostPatterns) IsPresent added in v0.1.22

func (instance HostPatterns) IsPresent() bool

func (HostPatterns) Matches added in v0.1.22

func (instance HostPatterns) Matches(test string) bool

func (*HostPatterns) Set added in v0.1.22

func (instance *HostPatterns) Set(plain string) error

func (HostPatterns) String added in v0.1.22

func (instance HostPatterns) String() string

type KubernetesBasedRepository added in v0.1.6

type KubernetesBasedRepository struct {
	Environment  *kubernetes.Environment
	ByHostRules  *ByHost
	ResyncAfter  time.Duration
	IngressClass []string
	HostWildcard value.ForcibleString

	CertificatesSecret string
	CertificatesByHost CertificatesByHost
	OptionsFactory     OptionsFactory
}

func (*KubernetesBasedRepository) All added in v0.1.6

func (instance *KubernetesBasedRepository) All(consumer func(Rule) error) error

func (*KubernetesBasedRepository) FindBy added in v0.1.6

func (instance *KubernetesBasedRepository) FindBy(q Query) (Rules, error)

func (*KubernetesBasedRepository) FindCertificatesBy added in v0.1.6

func (instance *KubernetesBasedRepository) FindCertificatesBy(q CertificateQuery) (Certificates, error)

func (*KubernetesBasedRepository) Init added in v0.1.6

func (instance *KubernetesBasedRepository) Init(stop support.Channel) error

func (*KubernetesBasedRepository) RegisterFlag added in v0.1.6

func (instance *KubernetesBasedRepository) RegisterFlag(fe support.FlagEnabled, appPrefix string) error

type Method added in v0.1.22

type Method string

func ParseMethod added in v0.1.22

func ParseMethod(plain string) (result Method, err error)

func (*Method) Set added in v0.1.22

func (instance *Method) Set(plain string) error

func (Method) String added in v0.1.22

func (instance Method) String() string

type Methods added in v0.1.22

type Methods []Method

func ParseMethods added in v0.1.22

func ParseMethods(plain string) (result Methods, err error)

func (Methods) Get added in v0.1.22

func (instance Methods) Get() interface{}

func (Methods) IsPresent added in v0.1.22

func (instance Methods) IsPresent() bool

func (Methods) Matches added in v0.1.22

func (instance Methods) Matches(test Method) bool

func (*Methods) Set added in v0.1.22

func (instance *Methods) Set(plain string) error

func (Methods) String added in v0.1.22

func (instance Methods) String() string

type OnAdded

type OnAdded func(path []string, r Rule)

type OnRemoved

type OnRemoved func(path []string, r Rule)

type Options

type Options map[string]OptionsPart

func (Options) IsRelevant

func (instance Options) IsRelevant() bool

func (*Options) Set added in v0.1.6

func (instance *Options) Set(annotations Annotations) error

type OptionsCors added in v0.1.6

type OptionsCors struct {
	Enabled            value.ForcibleBool `json:"enabled,omitempty"`
	AllowedOriginsHost HostPatterns       `json:"allowedOriginsHost,omitempty"`
	AllowedMethods     Methods            `json:"allowedMethods,omitempty"`
	AllowedHeaders     HeaderNames        `json:"allowedHeaders,omitempty"`
	AllowedCredentials value.Bool         `json:"allowedCredentials,omitempty"`
	MaxAge             value.Duration     `json:"maxAge,omitempty"`
}

func OptionsCorsOf added in v0.1.6

func OptionsCorsOf(rule Rule) *OptionsCors

func (OptionsCors) IsRelevant added in v0.1.6

func (instance OptionsCors) IsRelevant() bool

func (OptionsCors) Name added in v0.1.6

func (instance OptionsCors) Name() string

func (*OptionsCors) Set added in v0.1.6

func (instance *OptionsCors) Set(annotations Annotations) (err error)

type OptionsCustomHeaders added in v0.1.6

type OptionsCustomHeaders struct {
	RequestHeaders  Headers `json:"requestHeaders,omitempty"`
	ResponseHeaders Headers `json:"responseHeaders,omitempty"`
}

func OptionsCustomHeadersOf added in v0.1.6

func OptionsCustomHeadersOf(rule Rule) *OptionsCustomHeaders

func (OptionsCustomHeaders) IsRelevant added in v0.1.6

func (instance OptionsCustomHeaders) IsRelevant() bool

func (OptionsCustomHeaders) Name added in v0.1.6

func (instance OptionsCustomHeaders) Name() string

func (*OptionsCustomHeaders) Set added in v0.1.6

func (instance *OptionsCustomHeaders) Set(annotations Annotations) (err error)

type OptionsEncoding added in v0.1.14

type OptionsEncoding struct {
	TransportEncoding []string `json:"transportEncoding,omitempty"`
}

func OptionsEncodingOf added in v0.1.14

func OptionsEncodingOf(rule Rule) *OptionsEncoding

func (OptionsEncoding) IsRelevant added in v0.1.14

func (instance OptionsEncoding) IsRelevant() bool

func (OptionsEncoding) Name added in v0.1.14

func (instance OptionsEncoding) Name() string

func (*OptionsEncoding) Set added in v0.1.14

func (instance *OptionsEncoding) Set(annotations Annotations) (err error)

type OptionsFactory added in v0.1.6

type OptionsFactory func() Options
var (
	DefaultOptionsFactory OptionsFactory = newOptions
)

type OptionsMatching added in v0.4.0

type OptionsMatching struct {
	HostWildcard value.String `json:"wildcardPattern,omitempty"`
}

func OptionsMatchingOf added in v0.4.0

func OptionsMatchingOf(rule Rule) *OptionsMatching

func (OptionsMatching) IsRelevant added in v0.4.0

func (instance OptionsMatching) IsRelevant() bool

func (OptionsMatching) Name added in v0.4.0

func (instance OptionsMatching) Name() string

func (*OptionsMatching) Set added in v0.4.0

func (instance *OptionsMatching) Set(annotations Annotations) (err error)

type OptionsPart added in v0.1.6

type OptionsPart interface {
	Name() string
	IsRelevant() bool
	Set(annotations Annotations) error
}

func RegisterDefaultOptionsPart added in v0.1.6

func RegisterDefaultOptionsPart(prototype OptionsPart) OptionsPart

type OptionsPrefix added in v0.1.6

type OptionsPrefix struct {
	StripRulePathPrefix value.Bool `json:"stripRulePathPrefix,omitempty"`
	PathPrefix          []string   `json:"pathPrefix,omitempty"`
	XForwardedPrefix    value.Bool `json:"xForwardedPrefix,omitempty"`
}

func OptionsPrefixOf added in v0.1.6

func OptionsPrefixOf(rule Rule) *OptionsPrefix

func (OptionsPrefix) IsRelevant added in v0.1.6

func (instance OptionsPrefix) IsRelevant() bool

func (OptionsPrefix) Name added in v0.1.6

func (instance OptionsPrefix) Name() string

func (*OptionsPrefix) Set added in v0.1.6

func (instance *OptionsPrefix) Set(annotations Annotations) (err error)

type OptionsSecure added in v0.1.6

type OptionsSecure struct {
	ForceSecure        value.Bool `json:"forceSecure,omitempty"`
	WhitelistedRemotes []Address  `json:"whitelistedRemotes,omitempty"`
}

func OptionsSecureOf added in v0.1.6

func OptionsSecureOf(rule Rule) *OptionsSecure

func (OptionsSecure) IsRelevant added in v0.1.6

func (instance OptionsSecure) IsRelevant() bool

func (OptionsSecure) Name added in v0.1.6

func (instance OptionsSecure) Name() string

func (*OptionsSecure) Set added in v0.1.6

func (instance *OptionsSecure) Set(annotations Annotations) (err error)

type Predicate

type Predicate func(path []string, r Rule) bool

func PredicateBySource

func PredicateBySource(reference SourceReference) Predicate

type Query

type Query struct {
	Host value.Fqdn
	Path string
}

type Repository

type Repository interface {
	support.FlagRegistrar
	Init(stop support.Channel) error
	All(consumer func(Rule) error) error
	FindBy(Query) (Rules, error)
}

type Rule

type Rule interface {
	Host() value.WildcardSupportingFqdn
	Path() []string
	Source() SourceReference
	Backend() net.Addr
	Options() Options
	Statistics() *Statistics
}

func NewRule

func NewRule(host value.WildcardSupportingFqdn, path []string, source SourceReference, backend net.Addr, options Options) Rule

type Rules

type Rules interface {
	Get(int) Rule
	Len() int
	Any() Rule
}

type SourceReference

type SourceReference interface {
	Namespace() string
	Name() string
	Type() string
	String() string
	Equals(SourceReference) bool
}

type Statistics

type Statistics struct {
	// contains filtered or unexported fields
}

func (*Statistics) MarkUsed

func (instance *Statistics) MarkUsed(duration time.Duration)

func (*Statistics) MarshalJSON

func (instance *Statistics) MarshalJSON() ([]byte, error)

func (*Statistics) NumberOfUsages

func (instance *Statistics) NumberOfUsages() uint64

func (*Statistics) TotalDuration

func (instance *Statistics) TotalDuration() time.Duration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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