utils

package
v1.17.9 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MultipleTargetRefErrStr = "" /* 132-byte string literal not displayed */

TODO: remove this as part of https://github.com/solo-io/solo-projects/issues/6286

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())
	}
)
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,
) []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

1. older with section name

2. newer with section name

3. older without section name

4. newer without section name

func SortByCreationTime

func SortByCreationTime(objs interface{})

SortByCreationTime accepts a slice of client.Object instances and sorts it by creation timestamp in ascending order. It panics if the argument isn't a slice, or if it is a slice of a type that does not implement client.Object.

Types

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

Jump to

Keyboard shortcuts

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