utils

package
v0.11.5-merged-prereqs Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 11 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 (
	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 FindExtensionRefFilter

func FindExtensionRefFilter(
	rule *gwv1.HTTPRouteRule,
	gk schema.GroupKind,
) *gwv1.HTTPRouteFilter

FindExtensionRefFilter finds the first instance of an ExtensionRef filter 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