generic

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const InjectAnnotationKey = "chaos-mesh.org/inject"

Variables

This section is empty.

Functions

func FilterObjectsByMode

func FilterObjectsByMode(mode v1alpha1.SelectorMode, value string, count int) ([]uint, error)

FilterObjectsByMode filters objects by mode

func RandomFixedIndexes

func RandomFixedIndexes(start, end, count uint) []uint

RandomFixedIndexes returns the `count` random indexes between `start` and `end`. [start, end)

Types

type ListFunc

type ListFunc func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

type Option

type Option struct {
	ClusterScoped         bool
	TargetNamespace       string
	EnableFilterNamespace bool
}

type Selector

type Selector interface {
	// ListFunc returns the function to list object from kubernetes cluster.
	// If no method is specified, returns `nil` directly. (default: `List` function of `client.Client`)
	// If needed, `List` function of `client.Reader` can be returned. Only `field selector` uses it for now.
	// When registering the Selector, it's important to note that multiple ListFunc will be overwritten in the SelectorChain.
	ListFunc(client.Reader) ListFunc
	// ListOption returns the client.ListOption that modifies options for a list request.
	// If no option is specified, returns `nil` directly.
	// When registering a Selector, it is important to note that multiple ListOptions will all apply to
	// the same `client.ListOptions` and will be overwritten if they have the same fields in the SelectorChain.
	ListOption() client.ListOption
	// Match returns whether the object matches the selector
	Match(client.Object) bool
}

Selector is an interface implemented by things that know how to list objects from cluster and whether this object matches the selector.

type SelectorChain

type SelectorChain []Selector

func (SelectorChain) ListObjects

func (s SelectorChain) ListObjects(c client.Client, r client.Reader,
	listObj func(listFunc ListFunc, opts client.ListOptions) error) error

func (SelectorChain) Match

func (s SelectorChain) Match(obj client.Object) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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