query

package
v2.0.0-main Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpRouteTargetField    = "http-route-target"
	TcpRouteTargetField     = "tcp-route-target"
	ReferenceGrantFromField = "ref-grant-from"
)

Variables

View Source
var (
	ErrNoMatchingListenerHostname = fmt.Errorf("no matching listener hostname")
	ErrNoMatchingParent           = fmt.Errorf("no matching parent")
	ErrNotAllowedByListeners      = fmt.Errorf("not allowed by listeners")
	ErrLocalObjRefMissingKind     = fmt.Errorf("localObjRef provided with empty kind")
	ErrCyclicReference            = fmt.Errorf("cyclic reference detected while evaluating delegated routes")
	ErrUnresolvedReference        = fmt.Errorf("unresolved reference")
)

Functions

func AllNamespace

func AllNamespace() func(krt.HandlerContext, string) bool

func IndexerByObjType

func IndexerByObjType(obj client.Object) []string

IndexerByObjType indexes objects based on the provided object type. The following object types are supported:

  • HTTPRoute
  • TCPRoute
  • ReferenceGrant

func IterateIndices

func IterateIndices(f func(client.Object, string, client.IndexerFunc) error) error

IterateIndices calls the provided function for each indexable object with the appropriate indexer function.

func ProcessBackendError

func ProcessBackendError(err error, reporter reports.ParentRefReporter)

func ReferenceAllowed

func ReferenceAllowed(ctx context.Context, fromgk metav1.GroupKind, fromns string, togk metav1.GroupKind, toname string, grantsInToNs []apiv1beta1.ReferenceGrant) bool

func SameNamespace

func SameNamespace(ns string) func(krt.HandlerContext, string) bool

Types

type BackendMap

type BackendMap[T any] struct {
	// contains filtered or unexported fields
}

BackendMap is a generic type used to manage mappings of backends for Gateway API configurations. It's designed to store and manage backend references, like services, and to associate those references with either data (of a generic type T) or errors.

func NewBackendMap

func NewBackendMap[T any]() BackendMap[T]

func (BackendMap[T]) Add

func (bm BackendMap[T]) Add(backendRef ir.ObjectSource, value T)

func (BackendMap[T]) AddError

func (bm BackendMap[T]) AddError(backendRef ir.ObjectSource, err error)

type Error

type Error struct {
	Reason apiv1.RouteConditionReason
	E      error
}

func (*Error) Error

func (e *Error) Error() string

Error implements error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

type From

type From interface {
	GroupKind() (metav1.GroupKind, error)
	Namespace() string
}

type FromObject

type FromObject struct {
	client.Object
	Scheme *runtime.Scheme
}

func (FromObject) GroupKind

func (f FromObject) GroupKind() (metav1.GroupKind, error)

func (FromObject) Namespace

func (f FromObject) Namespace() string

type GatewayQueries

type GatewayQueries interface {
	GetSecretForRef(kctx krt.HandlerContext, ctx context.Context, fromGk schema.GroupKind, fromns string, secretRef apiv1.SecretObjectReference) (*ir.Secret, error)

	// GetRoutesForGateway finds the top level xRoutes attached to the provided Gateway
	GetRoutesForGateway(kctx krt.HandlerContext, ctx context.Context, gw *gwv1.Gateway) (*RoutesForGwResult, error)
	// GetRouteChain resolves backends and delegated routes for a the provided xRoute object
	GetRouteChain(kctx krt.HandlerContext,
		ctx context.Context,
		route ir.Route,
		hostnames []string,
		parentRef gwv1.ParentReference,
	) *RouteInfo
}

type GroupKindNs

type GroupKindNs struct {
	// contains filtered or unexported fields
}

func NewGroupKindNs

func NewGroupKindNs(gk metav1.GroupKind, ns string) *GroupKindNs

func (*GroupKindNs) GroupKind

func (g *GroupKindNs) GroupKind() (metav1.GroupKind, error)

func (*GroupKindNs) Namespace

func (g *GroupKindNs) Namespace() string

type ListenerResult

type ListenerResult struct {
	Error  error
	Routes []*RouteInfo
}

type Namespaced

type Namespaced interface {
	GetName() string
	GetNamespace() string
}

type Option

type Option func(*options)

type RouteError

type RouteError struct {
	Route     ir.Route
	ParentRef apiv1.ParentReference
	Error     Error
}

type RouteInfo

type RouteInfo struct {
	// Object is the generic route object which could be HTTPRoute, TCPRoute, etc.
	Object ir.Route

	// ParentRef points to the Gateway (and optionally Listener) or HTTPRoute.
	ParentRef gwv1.ParentReference

	// ParentRef points to the Gateway (and optionally Listener).
	ListenerParentRef gwv1.ParentReference

	// hostnameOverrides can replace the HTTPRoute hostnames with those that intersect
	// the attached listener's hostname(s).
	HostnameOverrides []string

	// Children contains all delegate HTTPRoutes referenced in any rule of this
	// HTTPRoute, keyed by the backend ref for easy lookup.
	// This tree structure can have cyclic references. Check them when recursing through the tree.
	Children BackendMap[[]*RouteInfo]
}

RouteInfo contains pre-resolved backends (Services, Upstreams and delegated xRoutes) This allows all querying to happen upfront, and detailed logic for delegation to happen as part of translation.

func (*RouteInfo) Clone

func (r *RouteInfo) Clone() *RouteInfo

Clone creates a deep copy of the RouteInfo object.

func (*RouteInfo) GetChildrenForRef

func (r *RouteInfo) GetChildrenForRef(backendRef ir.ObjectSource) ([]*RouteInfo, error)

GetChildrenForRef fetches child routes for a given BackendObjectReference.

func (RouteInfo) GetKind

func (r RouteInfo) GetKind() string

GetKind returns the kind of the route.

func (RouteInfo) GetName

func (r RouteInfo) GetName() string

GetName returns the name of the route.

func (RouteInfo) GetNamespace

func (r RouteInfo) GetNamespace() string

GetNamespace returns the namespace of the route.

func (*RouteInfo) Hostnames

func (r *RouteInfo) Hostnames() []string

Hostnames returns the hostname overrides if they exist, otherwise it returns the hostnames specified in the HTTPRoute.

func (*RouteInfo) UniqueRouteName

func (r *RouteInfo) UniqueRouteName(ruleIdx, matchIdx int) string

UniqueRouteName returns a unique name for the route based on the route kind, name, namespace, and the given indexes.

type RoutesForGwResult

type RoutesForGwResult struct {
	// key is listener name
	ListenerResults map[string]*ListenerResult
	RouteErrors     []*RouteError
}

func NewRoutesForGwResult

func NewRoutesForGwResult() *RoutesForGwResult

NewRoutesForGwResult creates and returns a new RoutesForGwResult with initialized fields.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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