Documentation ¶
Overview ¶
Package utils contains utility functions for gateway
Index ¶
- Variables
- func BackendRefToServicePortName(client cache.Cache, route client.Object, ...) *fgwv2.ServicePortName
- func DeepCopy(dst any, src any) error
- func ExtensionRefToFilter(client cache.Cache, route client.Object, ...) *extv1alpha1.Filter
- func FilterEndpointSliceList(endpointSliceList *discoveryv1.EndpointSliceList, port corev1.ServicePort) []*discoveryv1.EndpointSlice
- func FindBackendLBPolicy(c cache.Cache, targetRef gwv1alpha2.LocalPolicyTargetReference, ...) (*gwpav1alpha2.BackendLBPolicy, bool)
- func FindBackendTLSPolicy(c cache.Cache, targetRef gwv1alpha2.LocalPolicyTargetReferenceWithSectionName, ...) (*gwv1alpha3.BackendTLSPolicy, bool)
- func FindEndpointPort(ports []corev1.EndpointPort, svcPort corev1.ServicePort) int32
- func FindEndpointSlicePort(ports []discoveryv1.EndpointPort, svcPort corev1.ServicePort) int32
- func FindGatewayClassByName(c cache.Cache, name string) (*gwv1.GatewayClass, error)
- func FindHealthCheckPolicy(c cache.Cache, targetRef gwv1alpha2.NamespacedPolicyTargetReference, ...) (*gwpav1alpha2.HealthCheckPolicy, *gwpav1alpha2.PortHealthCheck, bool)
- func FindMatchedReferenceGrant(from gwtypes.CrossNamespaceFrom, to gwtypes.CrossNamespaceTo, ...) *gwv1beta1.ReferenceGrant
- func FindRetryPolicy(c cache.Cache, targetRef gwv1alpha2.NamespacedPolicyTargetReference, ...) (*gwpav1alpha2.RetryPolicy, *gwpav1alpha2.PortRetry, bool)
- func GetActiveGateways(cache cache.Cache) []*gwv1.Gateway
- func GetActiveGatewaysInNamespace(cache cache.Cache, namespace string) []*gwv1.Gateway
- func GetAllowedListeners(client cache.Cache, gw *gwv1.Gateway, rps status.RouteParentStatusObject) []gwtypes.Listener
- func GetCARefGrants(c cache.Cache) []*gwv1beta1.ReferenceGrant
- func GetDefaultPort(svcPort corev1.ServicePort) int32
- func GetSecretRefGrants(c cache.Cache) []*gwv1beta1.ReferenceGrant
- func GetServicePort(svc *corev1.Service, port *int32) (corev1.ServicePort, error)
- func GetServiceRefGrants(c cache.Cache) []*gwv1beta1.ReferenceGrant
- func GetValidHostnames(listenerHostname *gwv1.Hostname, routeHostnames []gwv1.Hostname) []string
- func GetValidListenersForGateway(gw *gwv1.Gateway) []gwtypes.Listener
- func GroupPointer(group string) *gwv1.Group
- func HasAccessToBackendTargetRef(client cache.Cache, policy client.Object, ...) bool
- func HasAccessToTargetRef(policy client.Object, ref gwv1alpha2.NamespacedPolicyTargetReference, ...) bool
- func HostnameMatchesWildcardHostname(hostname, wildcardHostname string) bool
- func IsAcceptedGateway(gateway *gwv1.Gateway) bool
- func IsAcceptedGatewayClass(gatewayClass *gwv1.GatewayClass) bool
- func IsAcceptedPolicyAttachment(conditions []metav1.Condition) bool
- func IsActiveGateway(gateway *gwv1.Gateway) bool
- func IsActiveGatewayByConditions(conditions []metav1.Condition) bool
- func IsEffectiveRouteForParent(rsh status.RouteStatusObject, parentRef gwv1.ParentReference) bool
- func IsEndpointReady(ep discoveryv1.Endpoint) bool
- func IsListenerAccepted(listenerStatus gwv1.ListenerStatus) bool
- func IsListenerConflicted(listenerStatus gwv1.ListenerStatus) bool
- func IsListenerProgrammed(listenerStatus gwv1.ListenerStatus) bool
- func IsListenerResolvedRefs(listenerStatus gwv1.ListenerStatus) bool
- func IsListenerValid(s gwv1.ListenerStatus) bool
- func IsLocalObjRefToGateway(targetRef gwv1.LocalObjectReference, gateway types.NamespacedName) bool
- func IsPolicyAcceptedForAncestor(ancestorRef gwv1.ParentReference, ancestors []gwv1alpha2.PolicyAncestorStatus) bool
- func IsProgrammedGateway(gateway *gwv1.Gateway) bool
- func IsRefToGateway(parentRef gwv1.ParentReference, gateway types.NamespacedName) bool
- func IsTargetRefToGVK(targetRef gwv1alpha2.NamespacedPolicyTargetReference, ...) bool
- func IsTargetRefToTarget(policy client.Object, targetRef gwv1alpha2.NamespacedPolicyTargetReference, ...) bool
- func IsValidBackendRefToGroupKindOfService(ref gwv1.BackendObjectReference) bool
- func IsValidRefToGroupKindOfCA(ref gwv1.ObjectReference) bool
- func IsValidRefToGroupKindOfSecret(ref gwv1.SecretObjectReference) bool
- func IsValidTargetRefToGroupKindOfService(ref gwv1alpha2.NamespacedPolicyTargetReference) bool
- func NamespaceDerefOr(ns *gwv1.Namespace, defaultNs string) string
- func NamespaceMatches(client cache.Cache, namespaces *gwv1.RouteNamespaces, ...) bool
- func ObjectRefToCACertificate(client cache.Cache, referer client.Object, ref gwv1.ObjectReference, ...) []byte
- func SortResources[T client.Object](resources []T) []T
- func ToSlicePtr[T any](slice []T) []*T
- func ValidCrossNamespaceRef(from gwtypes.CrossNamespaceFrom, to gwtypes.CrossNamespaceTo, ...) bool
Constants ¶
This section is empty.
Variables ¶
var IsValidHostname = webhook.IsValidHostname
Functions ¶
func BackendRefToServicePortName ¶ added in v1.4.0
func BackendRefToServicePortName(client cache.Cache, route client.Object, backendRef gwv1.BackendObjectReference, rps status.RouteConditionAccessor) *fgwv2.ServicePortName
BackendRefToServicePortName converts a BackendRef to a ServicePortName for a given Route if the referent is a Kubernetes Service and the port is valid.
func ExtensionRefToFilter ¶ added in v1.4.0
func ExtensionRefToFilter(client cache.Cache, route client.Object, extensionRef *gwv1.LocalObjectReference) *extv1alpha1.Filter
ExtensionRefToFilter converts a LocalObjectReference to a Filter.
func FilterEndpointSliceList ¶ added in v1.4.0
func FilterEndpointSliceList(endpointSliceList *discoveryv1.EndpointSliceList, port corev1.ServicePort) []*discoveryv1.EndpointSlice
FilterEndpointSliceList filters the given EndpointSliceList to only include EndpointSlices that have a matching port.
func FindBackendLBPolicy ¶ added in v1.4.0
func FindBackendLBPolicy(c cache.Cache, targetRef gwv1alpha2.LocalPolicyTargetReference, routeNamespace string) (*gwpav1alpha2.BackendLBPolicy, bool)
FindBackendLBPolicy finds the BackendTLSPolicy for the given LocalPolicyTargetReference.
func FindBackendTLSPolicy ¶ added in v1.4.0
func FindBackendTLSPolicy(c cache.Cache, targetRef gwv1alpha2.LocalPolicyTargetReferenceWithSectionName, routeNamespace string) (*gwv1alpha3.BackendTLSPolicy, bool)
FindBackendTLSPolicy finds the BackendTLSPolicy for the given LocalPolicyTargetReferenceWithSectionName.
func FindEndpointPort ¶ added in v1.4.0
func FindEndpointPort(ports []corev1.EndpointPort, svcPort corev1.ServicePort) int32
FindEndpointPort finds the port in the EndpointPort slice that matches the ServicePort.
func FindEndpointSlicePort ¶ added in v1.4.0
func FindEndpointSlicePort(ports []discoveryv1.EndpointPort, svcPort corev1.ServicePort) int32
FindEndpointSlicePort finds the port in the EndpointSlice that matches the ServicePort.
func FindGatewayClassByName ¶ added in v1.4.0
FindGatewayClassByName returns the GatewayClass with the given name
func FindHealthCheckPolicy ¶ added in v1.4.0
func FindHealthCheckPolicy(c cache.Cache, targetRef gwv1alpha2.NamespacedPolicyTargetReference, routeNamespace string, svcPort *fgwv2.ServicePortName) (*gwpav1alpha2.HealthCheckPolicy, *gwpav1alpha2.PortHealthCheck, bool)
func FindMatchedReferenceGrant ¶ added in v1.4.0
func FindMatchedReferenceGrant(from gwtypes.CrossNamespaceFrom, to gwtypes.CrossNamespaceTo, referenceGrants []*gwv1beta1.ReferenceGrant) *gwv1beta1.ReferenceGrant
FindMatchedReferenceGrant returns if the reference is valid across namespaces based on the reference grants
func FindRetryPolicy ¶ added in v1.4.0
func FindRetryPolicy(c cache.Cache, targetRef gwv1alpha2.NamespacedPolicyTargetReference, routeNamespace string, svcPort *fgwv2.ServicePortName) (*gwpav1alpha2.RetryPolicy, *gwpav1alpha2.PortRetry, bool)
func GetActiveGateways ¶ added in v1.3.0
GetActiveGateways returns the active gateways
func GetActiveGatewaysInNamespace ¶ added in v1.4.0
GetActiveGatewaysInNamespace returns the active gateways in the namespace
func GetAllowedListeners ¶
func GetAllowedListeners(client cache.Cache, gw *gwv1.Gateway, rps status.RouteParentStatusObject) []gwtypes.Listener
GetAllowedListeners returns the allowed listeners
func GetCARefGrants ¶ added in v1.4.0
func GetCARefGrants(c cache.Cache) []*gwv1beta1.ReferenceGrant
GetCARefGrants returns all ReferenceGrants in the cache that target a Kubernetes Secret or ConfigMap
func GetDefaultPort ¶ added in v1.4.0
func GetDefaultPort(svcPort corev1.ServicePort) int32
GetDefaultPort returns the default port for the given ServicePort.
func GetSecretRefGrants ¶ added in v1.4.0
func GetSecretRefGrants(c cache.Cache) []*gwv1beta1.ReferenceGrant
GetSecretRefGrants returns all ReferenceGrants in the cache that target a Kubernetes Secret
func GetServicePort ¶ added in v1.4.0
GetServicePort returns the ServicePort for the given port.
func GetServiceRefGrants ¶ added in v1.4.0
func GetServiceRefGrants(c cache.Cache) []*gwv1beta1.ReferenceGrant
GetServiceRefGrants returns all ReferenceGrants in the cache that target a Kubernetes Service
func GetValidHostnames ¶
GetValidHostnames returns the valid hostnames
func GetValidListenersForGateway ¶ added in v1.3.0
GetValidListenersForGateway returns the valid listeners from the gateway
func GroupPointer ¶
GroupPointer returns a pointer to the given group
func HasAccessToBackendTargetRef ¶ added in v1.4.0
func HasAccessToBackendTargetRef(client cache.Cache, policy client.Object, targetRef gwv1alpha2.NamespacedPolicyTargetReference, pca status.PolicyAncestorStatusObject) bool
HasAccessToBackendTargetRef checks if the policy has access to the target reference which is a backend service
func HasAccessToTargetRef ¶ added in v1.3.0
func HasAccessToTargetRef(policy client.Object, ref gwv1alpha2.NamespacedPolicyTargetReference, referenceGrants []*gwv1beta1.ReferenceGrant) bool
HasAccessToTargetRef returns true if the policy has access to the target reference
func HostnameMatchesWildcardHostname ¶
HostnameMatchesWildcardHostname returns true if the hostname matches the wildcard hostname
func IsAcceptedGateway ¶
IsAcceptedGateway returns true if the gateway is accepted
func IsAcceptedGatewayClass ¶
func IsAcceptedGatewayClass(gatewayClass *gwv1.GatewayClass) bool
IsAcceptedGatewayClass returns true if the gateway class is accepted
func IsAcceptedPolicyAttachment ¶ added in v1.2.0
IsAcceptedPolicyAttachment returns true if the policy attachment is accepted
func IsActiveGateway ¶
IsActiveGateway returns true if the gateway is active, it stands for the gateway is accepted, programmed and has a valid listener
func IsActiveGatewayByConditions ¶ added in v1.4.0
func IsEffectiveRouteForParent ¶ added in v1.4.0
func IsEffectiveRouteForParent(rsh status.RouteStatusObject, parentRef gwv1.ParentReference) bool
IsEffectiveRouteForParent returns true if the route is accepted and all references are resolved
func IsEndpointReady ¶ added in v1.4.0
func IsEndpointReady(ep discoveryv1.Endpoint) bool
IsEndpointReady returns true if the given Endpoint is ready.
func IsListenerAccepted ¶
func IsListenerAccepted(listenerStatus gwv1.ListenerStatus) bool
IsListenerAccepted returns true if the listener is accepted
func IsListenerConflicted ¶ added in v1.4.0
func IsListenerConflicted(listenerStatus gwv1.ListenerStatus) bool
IsListenerConflicted returns true if the listener is conflicted
func IsListenerProgrammed ¶
func IsListenerProgrammed(listenerStatus gwv1.ListenerStatus) bool
IsListenerProgrammed returns true if the listener is programmed
func IsListenerResolvedRefs ¶ added in v1.4.0
func IsListenerResolvedRefs(listenerStatus gwv1.ListenerStatus) bool
IsListenerResolvedRefs returns true if the listener is resolved refs
func IsListenerValid ¶ added in v1.4.0
func IsListenerValid(s gwv1.ListenerStatus) bool
IsListenerValid returns true if the listener is valid
func IsLocalObjRefToGateway ¶ added in v1.4.0
func IsLocalObjRefToGateway(targetRef gwv1.LocalObjectReference, gateway types.NamespacedName) bool
func IsPolicyAcceptedForAncestor ¶ added in v1.4.0
func IsPolicyAcceptedForAncestor(ancestorRef gwv1.ParentReference, ancestors []gwv1alpha2.PolicyAncestorStatus) bool
func IsProgrammedGateway ¶ added in v1.4.0
IsProgrammedGateway returns true if the gateway is programmed
func IsRefToGateway ¶
func IsRefToGateway(parentRef gwv1.ParentReference, gateway types.NamespacedName) bool
IsRefToGateway returns true if the parent reference is to the gateway
func IsTargetRefToGVK ¶ added in v1.2.0
func IsTargetRefToGVK(targetRef gwv1alpha2.NamespacedPolicyTargetReference, gvk schema.GroupVersionKind) bool
IsTargetRefToGVK returns true if the target reference is to the given group version kind
func IsTargetRefToTarget ¶ added in v1.4.0
func IsTargetRefToTarget(policy client.Object, targetRef gwv1alpha2.NamespacedPolicyTargetReference, target client.Object) bool
IsTargetRefToTarget returns true if the target reference is to the target resource
func IsValidBackendRefToGroupKindOfService ¶ added in v1.4.0
func IsValidBackendRefToGroupKindOfService(ref gwv1.BackendObjectReference) bool
IsValidBackendRefToGroupKindOfService returns true if the reference is to a Service in the core group
func IsValidRefToGroupKindOfCA ¶ added in v1.4.0
func IsValidRefToGroupKindOfCA(ref gwv1.ObjectReference) bool
IsValidRefToGroupKindOfCA returns true if the reference is to a ConfigMap or Secret in the core group
func IsValidRefToGroupKindOfSecret ¶ added in v1.4.0
func IsValidRefToGroupKindOfSecret(ref gwv1.SecretObjectReference) bool
IsValidRefToGroupKindOfSecret returns true if the reference is to a Secret in the core group
func IsValidTargetRefToGroupKindOfService ¶ added in v1.4.0
func IsValidTargetRefToGroupKindOfService(ref gwv1alpha2.NamespacedPolicyTargetReference) bool
IsValidTargetRefToGroupKindOfService checks if the target reference is valid to the group kind of service
func NamespaceDerefOr ¶ added in v1.4.0
NamespaceDerefOr returns the namespace if it is not nil, otherwise returns the default namespace
func NamespaceMatches ¶ added in v1.3.0
func NamespaceMatches(client cache.Cache, namespaces *gwv1.RouteNamespaces, gatewayNamespace, routeNamespace string) bool
NamespaceMatches returns true if the namespace matches
func ObjectRefToCACertificate ¶ added in v1.4.0
func ObjectRefToCACertificate(client cache.Cache, referer client.Object, ref gwv1.ObjectReference, ancestorStatus status.PolicyAncestorStatusObject) []byte
ObjectRefToCACertificate converts an ObjectReference to a CA Certificate. It supports Kubernetes Secret and ConfigMap as the referent.
func SortResources ¶ added in v1.4.0
SortResources sorts the resources by creation timestamp and name
func ToSlicePtr ¶ added in v1.4.0
func ToSlicePtr[T any](slice []T) []*T
func ValidCrossNamespaceRef ¶ added in v1.3.0
func ValidCrossNamespaceRef(from gwtypes.CrossNamespaceFrom, to gwtypes.CrossNamespaceTo, referenceGrants []*gwv1beta1.ReferenceGrant) bool
ValidCrossNamespaceRef returns if the reference is valid across namespaces based on the reference grants
Types ¶
This section is empty.