selectors

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineSelectors

func CombineSelectors(selectors ...labels.Selector) labels.Selector

func GetNamespacesMatchingSelectors

func GetNamespacesMatchingSelectors(
	ctx context.Context,
	c client.Reader,
	namespaceSelector []NamespaceSelector,
) (namespaces []corev1.Namespace, err error)

Takes a list of NamespaceSelectors and returns unique ordered Namespaces.

func GetNamespacesMatchingSelectorsStrings

func GetNamespacesMatchingSelectorsStrings(
	ctx context.Context,
	c client.Reader,
	namespaceSelector []NamespaceSelector,
) ([]string, error)

func ListBySelectors

func ListBySelectors[T client.Object](
	ctx context.Context,
	c client.Reader,
	list client.ObjectList,
	selectors []*metav1.LabelSelector,
) ([]T, error)

ListBySelectors lists objects of type T (using list L), then returns all items that match ANY of the provided LabelSelectors. The result is unique by namespace/name.

func MatchesSelector

func MatchesSelector(objLabels labels.Set, selector metav1.LabelSelector) (bool, error)

Attempt so verify multiple selector objects against a labels.Set If selectors are not set, it is always considered a match.

func MatchesSelectors

func MatchesSelectors(objLabels labels.Set, selectors []metav1.LabelSelector) bool

Attempt so verify multiple selector objects against a labels.Set If selectors are not set, it is always considered a match.

Types

type CompiledFieldSelector added in v0.13.4

type CompiledFieldSelector struct {
	Raw      string
	Path     string
	Operator FieldSelectorOperator
	Value    string
	Compiled *jsonpath.CompiledJSONPath
}

type CompiledSelectorWithFields

type CompiledSelectorWithFields struct {
	LabelSelector labels.Selector
	FieldMatchers []CompiledFieldSelector
}

type FieldSelectorOperator added in v0.13.4

type FieldSelectorOperator string
const (
	FieldSelectorTruthy FieldSelectorOperator = "truthy"
	FieldSelectorEquals FieldSelectorOperator = "equals"
)

type NamespaceSelector

type NamespaceSelector struct {
	// Select Items based on their labels. If the namespaceSelector is also set, the selector is applied
	// to items within the selected namespaces. Otherwise for all the items.
	*metav1.LabelSelector `json:",inline"`
}

Selector for resources and their labels or selecting origin namespaces +kubebuilder:object:generate=true

func (*NamespaceSelector) DeepCopy

func (in *NamespaceSelector) DeepCopy() *NamespaceSelector

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespaceSelector.

func (*NamespaceSelector) DeepCopyInto

func (in *NamespaceSelector) DeepCopyInto(out *NamespaceSelector)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*NamespaceSelector) GetMatchingNamespaces

func (s *NamespaceSelector) GetMatchingNamespaces(
	ctx context.Context,
	c client.Reader,
) ([]corev1.Namespace, error)

GetMatchingNamespaces retrieves the list of namespaces that match the NamespaceSelector.

type SelectorWithFields

type SelectorWithFields struct {
	// Select Items based on their labels.
	*metav1.LabelSelector `json:",inline"`

	// Additional boolean JSONPath expressions.
	// All must evaluate to true for this selector to match.
	// +optional
	FieldSelectors []string `json:"fieldSelectors,omitempty"`
}

+kubebuilder:object:generate=true

func (*SelectorWithFields) DeepCopy

func (in *SelectorWithFields) DeepCopy() *SelectorWithFields

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelectorWithFields.

func (*SelectorWithFields) DeepCopyInto

func (in *SelectorWithFields) DeepCopyInto(out *SelectorWithFields)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SelectorWithNamespaceSelector

type SelectorWithNamespaceSelector struct {
	// Select Items based on their labels. If the namespaceSelector is also set, the selector is applied
	// to items within the selected namespaces. Otherwise for all the items.
	*metav1.LabelSelector `json:",inline"`

	// NamespaceSelector for filtering namespaces by labels where items can be located in
	NamespaceSelector *NamespaceSelector `json:"namespaceSelector,omitempty"`
}

Selector for resources and their labels or selecting origin namespaces +kubebuilder:object:generate=true

func (*SelectorWithNamespaceSelector) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelectorWithNamespaceSelector.

func (*SelectorWithNamespaceSelector) DeepCopyInto

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*SelectorWithNamespaceSelector) MatchObjects

func (s *SelectorWithNamespaceSelector) MatchObjects(
	ctx context.Context,
	c client.Reader,
	objects []metav1.Object,
) ([]metav1.Object, error)

Jump to

Keyboard shortcuts

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