filter

package
v0.0.0-...-31a7945 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const K8sCoreGroupExactMatch = "core"

K8sCoreGroupExactMatch is sentinel value that only matches K8s core group of ""

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupVersionResourceList

type GroupVersionResourceList []schema.GroupVersionResource

GroupVersionResourceList is a collection of GroupVersionResource objects

func (GroupVersionResourceList) Exclude

Exclude returns a GroupVersionResourceList with resources removed that should be excluded according to the ResourceTypeMatcher filter

func (GroupVersionResourceList) Include

Include returns a GroupVersionResourceList that should be included according to the ResourceTypeMatcher filter

type Resource

type Resource struct {
	Name           string
	GVR            schema.GroupVersionResource
	ResourceLabels map[string]string
}

Resource represents a named Kubernetes object (name + GVR). This provides methods to use for filtering/selection.

Note: This does not include 'Namespace'. The assumption is that the caller is responsible for determining what namespace scope to use for filtering

type ResourceList

type ResourceList []Resource

ResourceList is a collection of Resource objects

func (ResourceList) Exclude

Exclude returns any resources from the ResourceList that do not match the criteria in the specified ResourceMatcher

func (ResourceList) Include

Include returns any resources from the ResourceList that match the criteria in the specified ResourceMatcher

type ResourceMatcher

type ResourceMatcher []ResourceRequirement

ResourceMatcher is a collection of ResourceRequirement objects for filtering resources

func (ResourceMatcher) All

func (rm ResourceMatcher) All(name string, gvr schema.GroupVersionResource, resourceLabels map[string]string) bool

All returns true if the specified resource matches all of the requirements in `ResourceMatcher`

func (ResourceMatcher) Any

func (rm ResourceMatcher) Any(name string, gvr schema.GroupVersionResource, resourceLabels map[string]string) bool

Any returns true if the specified resource matches any of the requirements in `ResourceMatcher`

func (ResourceMatcher) Empty

func (rm ResourceMatcher) Empty() bool

Empty returns true if ResourceMatcher has no ResourceRequirements

func (ResourceMatcher) TypeMatcher

func (rm ResourceMatcher) TypeMatcher(usageInclusion bool) ResourceTypeMatcher

TypeMatcher constructs a resource type matcher based on a `ResourceMatcher`

The `usageInclusion` flag should be set to true if the type matcher will be used as an include filter

type ResourceRequirement

type ResourceRequirement struct {
	// Provides the Name of the resource object
	corev1.LocalObjectReference `json:",inline,omitempty"`
	// Provides the Group, Version, and Resource values (GVR)
	ResourceTypeRequirement `json:",inline,omitempty"`
	// Specifies a set of label requirements to be used as filters for matches
	metav1.LabelSelector `json:",inline,omitempty"`
}

ResourceRequirement allows specifying a resource requirement by type and/or name

func (ResourceRequirement) DeepCopyInto

func (r ResourceRequirement) DeepCopyInto(out *ResourceRequirement)

DeepCopyInto provides explicit deep copy implementation to avoid

func (ResourceRequirement) Matches

func (r ResourceRequirement) Matches(name string, gvr schema.GroupVersionResource, resourceLabels map[string]string) bool

Matches returns true if the specified resource name/GVR/labels matches the requirement

type ResourceTypeMatcher

type ResourceTypeMatcher []ResourceTypeRequirement

ResourceTypeMatcher is a collection of ResourceTypeRequirement objects

func JoinResourceTypeMatchers

func JoinResourceTypeMatchers(ms ...ResourceTypeMatcher) ResourceTypeMatcher

JoinResourceTypeMatchers joins multiple ResourceTypeMatchers into one

func (ResourceTypeMatcher) All

All returns true if all resources in the collection match

func (ResourceTypeMatcher) Any

Any returns true if there are any GVR matches in the collection

func (ResourceTypeMatcher) Empty

func (rtm ResourceTypeMatcher) Empty() bool

Empty returns true if ResourceTypeMatcher collection has no objects

func (ResourceTypeMatcher) ResourceMatcher

func (rtm ResourceTypeMatcher) ResourceMatcher() ResourceMatcher

ResourceMatcher constructs a resource matcher based on a `ResourceTypeMatcher`

type ResourceTypeRequirement

type ResourceTypeRequirement struct {
	Group    string `json:"group,omitempty"`
	Version  string `json:"version,omitempty"`
	Resource string `json:"resource,omitempty"`
}

ResourceTypeRequirement contains group, version and resource values

func (ResourceTypeRequirement) Empty

func (rtr ResourceTypeRequirement) Empty() bool

Empty returns true if ResourceTypeRequirement has no fields set

func (ResourceTypeRequirement) Matches

Matches returns true if group, version and resource values match or are empty Group value of K8sCoreGroupExactMatch only matches K8s core group of ""

type Specs

func (Specs) Exclude

func (s Specs) Exclude(ms ...ResourceTypeMatcher) Specs

func (Specs) Include

func (s Specs) Include(ms ...ResourceTypeMatcher) Specs

Jump to

Keyboard shortcuts

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