plugins

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 22 Imported by: 49

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_api_pkg_plugins_config_proto protoreflect.FileDescriptor

Functions

func ComparePluginOrder

func ComparePluginOrder(a, b string) bool

func ComparePluginOrderInt

func ComparePluginOrderInt(a, b string) int

func DisablePlugin added in v0.3.0

func DisablePlugin(name string)

This method should be called at startup. There will be race if it's called during runtime.

func IteratePlugin added in v0.3.0

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

func IteratePluginType added in v0.5.0

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

func RegisterHTTPFilterFactoryAndParser added in v0.3.0

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

func RegisterPlugin added in v0.3.0

func RegisterPlugin(name string, plugin Plugin)

func RegisterPluginType added in v0.3.0

func RegisterPluginType(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{}) (interface{}, error)
	Merge(parentConfig interface{}, childConfig interface{}) interface{}
	NonBlockingPhases() api.Phase
}

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 added in v0.3.0

func LoadHTTPFilterFactoryAndParser(name string) *FilterFactoryAndParser

type GoPlugin

type GoPlugin interface {
	Plugin

	Factory() api.FilterFactory
}

type HTTPNativePlugin added in v0.3.0

type HTTPNativePlugin interface {
	NativePlugin

	HTTPFilterConfigPlaceholder() map[string]interface{}
}

type HTTPNativePluginHasRouteConfigWrapper added in v0.3.0

type HTTPNativePluginHasRouteConfigWrapper 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 Initer

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

type MockConsumerPlugin

type MockConsumerPlugin struct {
	MockPlugin
}

func (*MockConsumerPlugin) ConsumerConfig

func (m *MockConsumerPlugin) ConsumerConfig() api.PluginConsumerConfig

func (*MockConsumerPlugin) Order

func (m *MockConsumerPlugin) Order() PluginOrder

type MockHTTPNativePlugin added in v0.3.0

type MockHTTPNativePlugin struct {
	MockNativePlugin
}

func (*MockHTTPNativePlugin) HTTPFilterConfigPlaceholder added in v0.3.0

func (m *MockHTTPNativePlugin) HTTPFilterConfigPlaceholder() map[string]interface{}

type MockNativePlugin

type MockNativePlugin struct {
	PluginMethodDefaultImpl
}

func (*MockNativePlugin) Config

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

func (*MockNativePlugin) ConfigTypeURL added in v0.3.0

func (m *MockNativePlugin) ConfigTypeURL() string

func (*MockNativePlugin) Order

func (m *MockNativePlugin) Order() PluginOrder

type MockNetworkNativePlugin added in v0.3.0

type MockNetworkNativePlugin struct {
	MockNativePlugin
}

func (*MockNetworkNativePlugin) Order added in v0.3.0

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

	ConfigTypeURL() string
}

type Plugin

type Plugin interface {
	Config() api.PluginConfig

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

func LoadPlugin added in v0.3.0

func LoadPlugin(name string) Plugin

func LoadPluginType added in v0.3.0

func LoadPluginType(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{}) (res interface{}, err 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) NonBlockingPhases added in v0.5.0

func (p *PluginMethodDefaultImpl) NonBlockingPhases() api.Phase

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 (
	// Only for Listener Native plugins
	OrderPositionListener PluginOrderPosition = iota
	// Only for Network Native plugins
	OrderPositionNetwork

	// Only for HTTP Native plugins
	// The first position in the HTTP filters
	OrderPositionOuter

	// 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
)

func (PluginOrderPosition) String added in v0.3.0

func (p PluginOrderPosition) String() string

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
)

func (PluginType) String added in v0.3.0

func (p PluginType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳