query

package
v1.18.0-beta8 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	ErrMissingReferenceGrant      = fmt.Errorf("missing reference grant")
	ErrUnknownKind                = fmt.Errorf("unknown kind")
	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(string) bool

func IterateIndices

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

func ProcessBackendError

func ProcessBackendError(err error, reporter reports.ParentRefReporter)

func ProcessBackendRef

func ProcessBackendRef(obj client.Object, err error, reporter reports.ParentRefReporter, backendRef gwv1.BackendObjectReference) *string

ProcessBackendRef is meant to take the result of a call to `GetBackendForRef` as well as a reporter and the original ref. The return value is a pointer to a string which is the cluster_name of the upstream that the ref resolved to. This function will return nil if the ref is not valid. This function will also set the appropriate condition on the parent via the reporter.

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(string) bool

Types

type BackendMap

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

func NewBackendMap

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

func (BackendMap[T]) Add

func (bm BackendMap[T]) Add(backendRef gwv1.BackendObjectReference, value T)

func (BackendMap[T]) AddError

func (bm BackendMap[T]) AddError(backendRef gwv1.BackendObjectReference, 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 FromGkNs

type FromGkNs struct {
	Gk metav1.GroupKind
	Ns string
}

TODO(Law): remove this type entirely?

func (FromGkNs) GroupKind

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

func (FromGkNs) Namespace

func (f FromGkNs) 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 {
	ObjToFrom(obj client.Object) From

	// Given a backendRef that resides in namespace obj, return the service that backs it.
	// This will error with `ErrMissingReferenceGrant` if there is no reference grant allowing the reference
	// return value depends on the group/kind in the backendRef.
	GetBackendForRef(ctx context.Context, obj From, backendRef *apiv1.BackendObjectReference) (client.Object, error)

	GetSecretForRef(ctx context.Context, obj From, secretRef apiv1.SecretObjectReference) (client.Object, error)

	GetLocalObjRef(ctx context.Context, from From, localObjRef apiv1.LocalObjectReference) (client.Object, error)

	// GetRoutesForGateway finds the top level HTTPRoutes attached to a Gateway
	GetRoutesForGateway(ctx context.Context, gw *apiv1.Gateway) (RoutesForGwResult, error)
	// GetHTTPRouteChain resolves backends and delegated routes for a HTTPRoute
	GetHTTPRouteChain(ctx context.Context, route apiv1.HTTPRoute, hostnames []string, parentRef apiv1.ParentReference) *HTTPRouteInfo
}

func NewData

func NewData(c client.Client, scheme *runtime.Scheme) GatewayQueries

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 HTTPRouteInfo

type HTTPRouteInfo struct {
	// HTTPRoute with rules and matches filtered to only those
	// that are valid based on the parent rule.
	gwv1.HTTPRoute

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

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

	// Backends are pre-resolved here. This list will not contain delegates.
	// Map values are either client.Object or error (errors can be passed to ProcessBackendRef).
	// TODO should we ProcessBackendRef early and put cluster names here?)
	Backends BackendMap[client.Object]

	// 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[[]*HTTPRouteInfo]
}

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

func (*HTTPRouteInfo) Clone

func (hr *HTTPRouteInfo) Clone() *HTTPRouteInfo

func (*HTTPRouteInfo) GetBackendForRef

func (hr *HTTPRouteInfo) GetBackendForRef(backendRef gwv1.BackendObjectReference) (client.Object, error)

func (*HTTPRouteInfo) GetChildrenForRef

func (hr *HTTPRouteInfo) GetChildrenForRef(backendRef gwv1.BackendObjectReference) ([]*HTTPRouteInfo, error)

func (HTTPRouteInfo) GetName

func (h HTTPRouteInfo) GetName() string

func (HTTPRouteInfo) GetNamespace

func (h HTTPRouteInfo) GetNamespace() string

func (*HTTPRouteInfo) Hostnames

func (hr *HTTPRouteInfo) Hostnames() []string

type ListenerResult

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

type Namespaced

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

type RouteError

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

type RoutesForGwResult

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

Jump to

Keyboard shortcuts

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