plugins

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_pkg_plugins_config_proto protoreflect.FileDescriptor

Functions

func ComparePluginOrder

func ComparePluginOrder(a, b string) bool

func ComparePluginOrderInt

func ComparePluginOrderInt(a, b string) int

func IterateHttpPlugin

func IterateHttpPlugin(f func(key string, value Plugin) bool)

func RegisterHttpFilterFactoryAndParser

func RegisterHttpFilterFactoryAndParser(name string, factory api.FilterFactory, parser FilterConfigParser)

func RegisterHttpPlugin

func RegisterHttpPlugin(name string, plugin Plugin)

Types

type Config

type Config struct {
	Pet string `protobuf:"bytes,1,opt,name=pet,proto3" json:"pet,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetPet

func (x *Config) GetPet() string

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

func (*Config) Validate

func (m *Config) Validate() error

Validate checks the field values on Config with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*Config) ValidateAll

func (m *Config) ValidateAll() error

ValidateAll checks the field values on Config with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in ConfigMultiError, or nil if none found.

type ConfigMultiError

type ConfigMultiError []error

ConfigMultiError is an error wrapping multiple validation errors returned by Config.ValidateAll() if the designated constraints aren't met.

func (ConfigMultiError) AllErrors

func (m ConfigMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (ConfigMultiError) Error

func (m ConfigMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type ConfigValidationError

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

ConfigValidationError is the validation error returned by Config.Validate if the designated constraints aren't met.

func (ConfigValidationError) Cause

func (e ConfigValidationError) Cause() error

Cause function returns cause value.

func (ConfigValidationError) Error

func (e ConfigValidationError) Error() string

Error satisfies the builtin error interface

func (ConfigValidationError) ErrorName

func (e ConfigValidationError) ErrorName() string

ErrorName returns error name.

func (ConfigValidationError) Field

func (e ConfigValidationError) Field() string

Field function returns field value.

func (ConfigValidationError) Key

func (e ConfigValidationError) Key() bool

Key function returns key value.

func (ConfigValidationError) Reason

func (e ConfigValidationError) Reason() string

Reason function returns reason value.

type ConsumerPlugin

type ConsumerPlugin interface {
	Plugin

	ConsumerConfig() api.PluginConsumerConfig
}

type FilterConfigParser

type FilterConfigParser interface {
	Parse(input interface{}, callbacks api.ConfigCallbackHandler) (interface{}, error)
	Merge(parentConfig interface{}, childConfig interface{}) interface{}
}

Here we introduce extra struct to avoid cyclic import between pkg/filtermanager and pkg/plugins

type FilterFactoryAndParser

type FilterFactoryAndParser struct {
	ConfigParser FilterConfigParser
	Factory      api.FilterFactory
}

func LoadHttpFilterFactoryAndParser

func LoadHttpFilterFactoryAndParser(name string) *FilterFactoryAndParser

type GoPlugin

type GoPlugin interface {
	Plugin

	Factory() api.FilterFactory
}

type Initer

type Initer interface {
	Init(cb api.ConfigCallbackHandler) error
}

type MockPlugin

type MockPlugin struct {
	PluginMethodDefaultImpl
}

func (*MockPlugin) Config

func (m *MockPlugin) Config() api.PluginConfig

func (*MockPlugin) Factory

func (m *MockPlugin) Factory() api.FilterFactory

func (*MockPlugin) Merge

func (m *MockPlugin) Merge(parent interface{}, child interface{}) interface{}

type MockPluginConfig

type MockPluginConfig struct {
	Config
}

type NativePlugin

type NativePlugin interface {
	Plugin

	RouteConfigTypeURL() string
	HTTPFilterConfigPlaceholder() map[string]interface{}
}

type NativePluginHasRouteConfigWrapper

type NativePluginHasRouteConfigWrapper interface {
	// ToRouteConfig converts the raw config to the real RouteConfig. It's used in some native plugin
	// for better user experience.
	// The input `raw` is the configuration user provides in the CRD, the returned value is the
	// configuration that will be delivered in the xDS.
	ToRouteConfig(raw map[string]interface{}) map[string]interface{}
}

type Plugin

type Plugin interface {
	Config() api.PluginConfig

	// Optional methods
	Type() PluginType
	Order() PluginOrder
	Merge(parent interface{}, child interface{}) interface{}
}

func LoadHttpPlugin

func LoadHttpPlugin(name string) Plugin

type PluginConfigParser

type PluginConfigParser struct {
	GoPlugin
}

func NewPluginConfigParser

func NewPluginConfigParser(parser GoPlugin) *PluginConfigParser

func (*PluginConfigParser) Parse

func (cp *PluginConfigParser) Parse(any interface{}, callbacks api.ConfigCallbackHandler) (interface{}, error)

type PluginMethodDefaultImpl

type PluginMethodDefaultImpl struct{}

PluginMethodDefaultImpl provides reasonable implementation for optional methods

func (*PluginMethodDefaultImpl) Merge

func (p *PluginMethodDefaultImpl) Merge(parent interface{}, child interface{}) interface{}

func (*PluginMethodDefaultImpl) Order

func (*PluginMethodDefaultImpl) Type

type PluginOrder

type PluginOrder struct {
	Position  PluginOrderPosition
	Operation PluginOrderOperation
}

type PluginOrderOperation

type PluginOrderOperation int
const (
	OrderOperationInsertFirst PluginOrderOperation = -1
	OrderOperationNop         PluginOrderOperation = 0 // Nop is the default
	OrderOperationInsertLast  PluginOrderOperation = 1
)

If InsertFirst is specified, the plugin will be ordered from the beginning of the group. InsertLast is the opposite.

type PluginOrderPosition

type PluginOrderPosition int
const (
	OrderPositionOuter PluginOrderPosition = iota // First position. It's reserved for Native plugins.

	// Now goes the Go plugins
	OrderPositionAccess
	OrderPositionAuthn
	OrderPositionAuthz
	OrderPositionTraffic
	OrderPositionTransform
	OrderPositionUnspecified
	OrderPositionBeforeUpstream

	// Stats plugins are expected to be called mainly in the Log phase
	OrderPositionStats

	// Last position. It's reserved for Native plugins.
	OrderPositionInner
)

type PluginType

type PluginType int
const (
	TypeSecurity      PluginType = iota // Plugins like WAF, request validation, etc.
	TypeAuthn                           // Plugins do authentication
	TypeAuthz                           // Plugins do authorization
	TypeTraffic                         // Plugins do traffic control, like rate limit, circuit breaker, etc.
	TypeTransform                       // Plugins do request/response transform
	TypeObservability                   // Plugins do observability
	TypeGeneral
)

Jump to

Keyboard shortcuts

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