utils

package
v1.19.13 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const NamespacedNameKindSeparator = '/'

Variables

View Source
var (
	ErrUnexpectedListenerType = errors.New("unexpected listener type")
	ErrUnexpectedListener     = func(l *gloov1.Listener) error {
		return fmt.Errorf("%w: expected AggregateListener, got %T", ErrUnexpectedListenerType, l.GetListenerType())
	}

	ListenerTargetRefGVKs = []schema.GroupVersionKind{
		wellknown.GatewayGVK,
		wellknown.XListenerSetGVK,
	}
)
View Source
var ErrTypesNotEqual = fmt.Errorf("types not equal")

Functions

func FindAppliedRouteFilter

func FindAppliedRouteFilter(
	routeCtx *plugins.RouteContext,
	filterType gwv1.HTTPRouteFilterType,
) *gwv1.HTTPRouteFilter

FindAppliedRouteFilter finds the first instance of the filterType supplied in the Rule being processed. Returns nil if the Rule doesn't contain a filter of the provided Type

func FindAppliedRouteFilters

func FindAppliedRouteFilters(
	routeCtx *plugins.RouteContext,
	filterTypes ...gwv1.HTTPRouteFilterType,
) []gwv1.HTTPRouteFilter

FindAppliedRouteFilters finds all instances of the supplied filterTypes for the Rule supplied in the RouteContext. Should only be used for plugins that support multiple filters as part of a single Rule

func FindExtensionRefFilters added in v1.17.4

func FindExtensionRefFilters(
	rule *gwv1.HTTPRouteRule,
	gk schema.GroupKind,
) []gwv1.HTTPRouteFilter

FindExtensionRefFilters returns a list ExtensionRef filters that references the supplied GroupKind in the Rule being processed. Returns nil if the Rule doesn't contain a matching ExtensionRef filter

func GetExtensionRefObj

func GetExtensionRefObj[T client.Object](
	ctx context.Context,
	route *gwv1.HTTPRoute,
	queries query.GatewayQueries,
	extensionRef *gwv1.LocalObjectReference,
) (T, error)

GetExtensionRefObj uses the provided query engine to retrieve an ExtensionRef object and return the object of the same type as the type parameter. An error will be returned if the Get was unsuccessful or if the type parameter was not correct. A nil error indicates success and `obj` should be usable as normal.

func GetExtensionRefObjFrom

func GetExtensionRefObjFrom[T client.Object](
	ctx context.Context,
	from query.From,
	queries query.GatewayQueries,
	extensionRef *gwv1.LocalObjectReference,
) (T, error)

func GetPrioritizedListenerPolicies

func GetPrioritizedListenerPolicies[T client.Object](
	items []PolicyWithSectionedTargetRefs[T],
	listener *gwv1.Listener,
	parentGwName string,
	parentListenerSet *apixv1a1.XListenerSet,
) []T

GetPrioritizedListenerPolicies accepts a slice of Gateway-attached policies (that may explicitly target a specific Listener and returns a slice of these policies (or a subset) resources. The returned policy list is sorted by specificity in the order of

ListenerSet targetRefs:

  1. older with section name
  2. newer with section name
  3. older without section name
  4. newer without section name

Gateway targetRefs:

  1. older with section name
  2. newer with section name
  3. older without section name
  4. newer without section name

This function will process all targetRefs for each policy

func IndexTargetRefsNnk added in v1.19.0

func IndexTargetRefsNnk[T policyTargetReference](targetRefs []T, namespace string, gvks []schema.GroupVersionKind) []string

IndexTargetRefsNnk indexes a list of policy target references by namespace, name, and kind. The kinds parameter is a list of GroupVersionKinds that are allowed to be indexed, though version is ignored.

func IndexTargetRefsNns added in v1.19.0

func IndexTargetRefsNns[T policyTargetReference](targetRefs []T, namespace string, gvks []schema.GroupVersionKind) []string

IndexTargetRefsNns indexes a list of policy target references by namespace and name. The kinds parameter is a list of GroupVersionKinds that are allowed to be indexed, though version is ignored.

Types

type NamespacedNameKind added in v1.19.0

type NamespacedNameKind struct {
	Name      string
	Namespace string
	Kind      string
}

func (NamespacedNameKind) String added in v1.19.0

func (n NamespacedNameKind) String() string

type PolicyWithSectionedTargetRefs

type PolicyWithSectionedTargetRefs[T client.Object] interface {
	GetTargetRefs() []*skv2corev1.PolicyTargetReferenceWithSectionName
	GetObject() T
}

PolicyWithSectionedTargetRefs is a wrapper type to represent policy objects that attach via TargetRefWtihSectionName

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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