Documentation ¶
Index ¶
- Constants
- Variables
- func AllNamespace() func(string) bool
- func IndexerByObjType(obj client.Object) []string
- func IterateIndices(f func(client.Object, string, client.IndexerFunc) error) error
- func ProcessBackendError(err error, reporter reports.ParentRefReporter)
- func ProcessBackendRef(obj client.Object, err error, reporter reports.ParentRefReporter, ...) *string
- func ReferenceAllowed(ctx context.Context, fromgk metav1.GroupKind, fromns string, ...) bool
- func SameNamespace(ns string) func(string) bool
- type BackendMap
- type BackendRefResolver
- type Error
- type From
- type FromGkNs
- type FromObject
- type GatewayQueries
- type GroupKindNs
- type ListenerResult
- type Namespaced
- type Option
- type RouteError
- type RouteInfo
- func (r *RouteInfo) Clone() *RouteInfo
- func (r *RouteInfo) GetBackendForRef(backendRef gwv1.BackendObjectReference) (client.Object, error)
- func (r *RouteInfo) GetChildrenForRef(backendRef gwv1.BackendObjectReference) ([]*RouteInfo, error)
- func (r RouteInfo) GetKind() string
- func (r RouteInfo) GetName() string
- func (r RouteInfo) GetNamespace() string
- func (r *RouteInfo) Hostnames() []string
- func (r *RouteInfo) UniqueRouteName(ruleIdx, matchIdx int) string
- type RoutesForGwResult
Constants ¶
const ( HttpRouteTargetField = "http-route-target" TcpRouteTargetField = "tcp-route-target" ReferenceGrantFromField = "ref-grant-from" )
Variables ¶
var ( ErrMissingReferenceGrant = fmt.Errorf("missing reference grant") ErrUnknownBackendKind = fmt.Errorf("unknown backend 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 IndexerByObjType ¶ added in v1.18.0
IndexerByObjType indexes objects based on the provided object type. The following object types are supported:
- HTTPRoute
- TCPRoute
- ReferenceGrant
func IterateIndices ¶
IterateIndices calls the provided function for each indexable object with the appropriate indexer function.
func ProcessBackendError ¶ added in v1.18.0
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 SameNamespace ¶
Types ¶
type BackendMap ¶ added in v1.18.0
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 ¶ added in v1.18.0
func NewBackendMap[T any]() BackendMap[T]
func (BackendMap[T]) Add ¶ added in v1.18.0
func (bm BackendMap[T]) Add(backendRef gwv1.BackendObjectReference, value T)
func (BackendMap[T]) AddError ¶ added in v1.18.0
func (bm BackendMap[T]) AddError(backendRef gwv1.BackendObjectReference, err error)
type BackendRefResolver ¶ added in v1.18.0
type BackendRefResolver interface { // GetBackendForRef resolves a custom reference. When the bool return is false, // indicates that the resolver is not responsible for the given ref. GetBackendForRef(ctx context.Context, obj From, backend *apiv1.BackendObjectReference) (client.Object, error, bool) }
BackendRefResolver allows resolution of backendRefs with a custom format.
type Error ¶
type Error struct { Reason apiv1.RouteConditionReason E error }
type FromObject ¶
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 xRoutes attached to the provided Gateway GetRoutesForGateway(ctx context.Context, gw *apiv1.Gateway) (*RoutesForGwResult, error) // GetRouteChain resolves backends and delegated routes for a the provided xRoute object GetRouteChain(ctx context.Context, obj client.Object, hostnames []string, parentRef apiv1.ParentReference) *RouteInfo }
type GroupKindNs ¶
type GroupKindNs struct {
// contains filtered or unexported fields
}
func NewGroupKindNs ¶
func NewGroupKindNs(gk metav1.GroupKind, ns string) *GroupKindNs
func (*GroupKindNs) Namespace ¶
func (g *GroupKindNs) Namespace() string
type ListenerResult ¶
type Namespaced ¶ added in v1.18.0
type Option ¶ added in v1.18.0
type Option func(*options)
func WithBackendRefResolvers ¶ added in v1.18.0
func WithBackendRefResolvers( customBackendResolvers ...BackendRefResolver, ) Option
type RouteError ¶
type RouteError struct { Route client.Object ParentRef apiv1.ParentReference Error Error }
type RouteInfo ¶ added in v1.18.0
type RouteInfo struct { // Object is the generic route object which could be HTTPRoute, TCPRoute, etc. Object client.Object // 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[[]*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) GetBackendForRef ¶ added in v1.18.0
GetBackendForRef fetches a backend for a given BackendObjectReference.
func (*RouteInfo) GetChildrenForRef ¶ added in v1.18.0
func (r *RouteInfo) GetChildrenForRef(backendRef gwv1.BackendObjectReference) ([]*RouteInfo, error)
GetChildrenForRef fetches child routes for a given BackendObjectReference.
func (RouteInfo) GetNamespace ¶ added in v1.18.0
GetNamespace returns the namespace of the route.
func (*RouteInfo) Hostnames ¶ added in v1.18.0
Hostnames returns the hostname overrides if they exist, otherwise it returns the hostnames specified in the HTTPRoute.
func (*RouteInfo) UniqueRouteName ¶ added in v1.18.0
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 ¶ added in v1.18.0
func NewRoutesForGwResult() *RoutesForGwResult
NewRoutesForGwResult creates and returns a new RoutesForGwResult with initialized fields.