filter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MasterServiceFilterName filter is used to mutate the ClusterIP and https port of default/kubernetes service
	// in order to pods on edge nodes can access kube-apiserver directly by inClusterConfig.
	MasterServiceFilterName = "masterservice"

	// ServiceTopologyFilterName filter is used to reassemble endpointslice in order to make the service traffic
	// under the topology that defined by service.Annotation["openyurt.io/topologyKeys"]
	ServiceTopologyFilterName = "servicetopology"

	// DiscardCloudServiceFilterName filter is used to discard cloud service(like loadBalancer service)
	// on kube-proxy list/watch service request from edge nodes.
	DiscardCloudServiceFilterName = "discardcloudservice"

	// SkipDiscardServiceAnnotation is annotation used by LB service.
	// If end users want to use specified LB service at the edge side,
	// End users should add annotation["openyurt.io/skip-discard"]="true" for LB service.
	SkipDiscardServiceAnnotation = "openyurt.io/skip-discard"
)

Variables

View Source
var DisabledInCloudMode = []string{DiscardCloudServiceFilterName}

DisabledInCloudMode contains the filters that should be disabled when yurthub is working in cloud mode.

Functions

func NewFilterReadCloser

func NewFilterReadCloser(
	req *http.Request,
	rc io.ReadCloser,
	handler Handler,
	serializer *serializer.Serializer,
	ownerName string,
	stopCh <-chan struct{}) (int, io.ReadCloser, error)

NewFilterReadCloser create an filterReadCloser object

Types

type Approver

type Approver interface {
	Approve(req *http.Request) bool
	GetFilterName(req *http.Request) string
}

Approver check the response of specified request need to go through filter or not. and get the filter name for the specified request.

type Factory

type Factory func() (Runner, error)

type FilterInitializer

type FilterInitializer interface {
	Initialize(filter Runner) error
}

type FilterInitializers

type FilterInitializers []FilterInitializer

func (FilterInitializers) Initialize

func (fis FilterInitializers) Initialize(ins Runner) error

type Filters

type Filters struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewFilters

func NewFilters(disabledFilters []string) *Filters

func (*Filters) Enabled

func (fs *Filters) Enabled(name string) bool

func (*Filters) NewFromFilters

func (fs *Filters) NewFromFilters(initializer FilterInitializer) (map[string]Runner, error)

func (*Filters) Register

func (fs *Filters) Register(name string, fn Factory)

type Handler

type Handler interface {
	// StreamResponseFilter is used to filter processing of streaming data.
	StreamResponseFilter(rc io.ReadCloser, ch chan watch.Event) error

	// ObjectResponseFilter is used to filter processing of object data.
	ObjectResponseFilter(b []byte) ([]byte, error)
}

Handler customizes data filtering processing interface for each handler. In the data filtering framework, data is mainly divided into two types:

Object data: data returned by list/get request.
Streaming data: The data returned by the watch request will be continuously pushed to the edge by the cloud.

type Manager added in v0.7.0

type Manager struct {
	Approver
	NameToFilter map[string]Runner
}

func NewFilterManager added in v0.7.0

func NewFilterManager(sharedFactory informers.SharedInformerFactory, filters map[string]Runner) *Manager

func (*Manager) Approve added in v0.7.0

func (m *Manager) Approve(req *http.Request) bool

func (*Manager) Filter added in v0.7.0

func (m *Manager) Filter(req *http.Request, rc io.ReadCloser, stopCh <-chan struct{}) (int, io.ReadCloser, error)

type NodeGetter

type NodeGetter func(name string) (*v1.Node, error)

type Runner added in v0.7.0

type Runner interface {
	// Filter is used to filter data returned from the cloud.
	Filter(req *http.Request, rc io.ReadCloser, stopCh <-chan struct{}) (int, io.ReadCloser, error)
}

Runner is the actor for response filter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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