const InjectAnnotationKey = "chaos-mesh.org/inject"
func FilterObjectsByMode(mode v1alpha1.SelectorMode, value string, count int) ([]uint, error)
FilterObjectsByMode filters objects by mode
func RandomFixedIndexes(start, end, count uint) []uint
RandomFixedIndexes returns the `count` random indexes between `start` and `end`. [start, end)
type ListFunc func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
type Option struct {
ClusterScoped bool
TargetNamespace string
EnableFilterNamespace bool
}
Selector is an interface implemented by things that know how to list objects from cluster and whether this object matches the 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
}
type SelectorChain []Selector
func (s SelectorChain) ListObjects(c client.Client, r client.Reader, listObj func(listFunc ListFunc, opts client.ListOptions) error) error
func (s SelectorChain) Match(obj client.Object) bool