Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( AllRelations = []*topology.Relation{ GatewayParentGatewayClassRelation, HTTPRouteParentGatewaysRelation, HTTPRouteChildBackendRefsRelation, GatewayNamespace, HTTPRouteNamespace, BackendNamespace, } // GatewayParentGatewayClassRelation returns GatewayClass for the Gateway. GatewayParentGatewayClassRelation = &topology.Relation{ From: common.GatewayGK, To: common.GatewayClassGK, Name: "GatewayClass", NeighborFunc: func(u *unstructured.Unstructured) []common.GKNN { gateway := &gatewayv1.Gateway{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.UnstructuredContent(), gateway); err != nil { panic(fmt.Sprintf("failed to convert unstructured Gateway to structured: %v", err)) } return []common.GKNN{{ Group: common.GatewayClassGK.Group, Kind: common.GatewayClassGK.Kind, Name: string(gateway.Spec.GatewayClassName), }} }, } // HTTPRouteParentGatewayRelation returns Gateways which the HTTPRoute is // attached to. HTTPRouteParentGatewaysRelation = &topology.Relation{ From: common.HTTPRouteGK, To: common.GatewayGK, Name: "ParentRef", NeighborFunc: func(u *unstructured.Unstructured) []common.GKNN { httpRoute := &gatewayv1.HTTPRoute{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.UnstructuredContent(), httpRoute); err != nil { panic(fmt.Sprintf("failed to convert unstructured HTTPRoute to structured: %v", err)) } result := []common.GKNN{} for _, gatewayRef := range httpRoute.Spec.ParentRefs { namespace := httpRoute.GetNamespace() if namespace == "" { namespace = metav1.NamespaceDefault } if gatewayRef.Namespace != nil { namespace = string(*gatewayRef.Namespace) } result = append(result, common.GKNN{ Group: common.GatewayGK.Group, Kind: common.GatewayGK.Kind, Namespace: namespace, Name: string(gatewayRef.Name), }) } return result }, } // HTTPRouteChildBackendRefsRelation returns Backends which the HTTPRoute // references. HTTPRouteChildBackendRefsRelation = &topology.Relation{ From: common.HTTPRouteGK, To: common.ServiceGK, Name: "BackendRef", NeighborFunc: func(u *unstructured.Unstructured) []common.GKNN { httpRoute := &gatewayv1.HTTPRoute{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.UnstructuredContent(), httpRoute); err != nil { panic(fmt.Sprintf("failed to convert unstructured HTTPRoute to structured: %v", err)) } // Aggregate all BackendRefs var backendRefs []gatewayv1.BackendObjectReference for _, rule := range httpRoute.Spec.Rules { for _, backendRef := range rule.BackendRefs { backendRefs = append(backendRefs, backendRef.BackendObjectReference) } for _, filter := range rule.Filters { if filter.Type != gatewayv1.HTTPRouteFilterRequestMirror { continue } if filter.RequestMirror == nil { continue } backendRefs = append(backendRefs, filter.RequestMirror.BackendRef) } } resultSet := make(map[common.GKNN]bool) for _, backendRef := range backendRefs { objRef := common.GKNN{ Name: string(backendRef.Name), Namespace: httpRoute.GetNamespace(), } if backendRef.Group != nil { objRef.Group = string(*backendRef.Group) } if backendRef.Kind != nil { objRef.Kind = string(*backendRef.Kind) } else { objRef.Kind = common.ServiceGK.Kind } if backendRef.Namespace != nil { objRef.Namespace = string(*backendRef.Namespace) } resultSet[objRef] = true } // Return unique objRefs var result []common.GKNN for objRef := range resultSet { result = append(result, objRef) } return result }, } // GatewayNamespace returns the Namespace for the Gateway. GatewayNamespace = &topology.Relation{ From: common.GatewayGK, To: common.NamespaceGK, Name: "Namespace", NeighborFunc: func(u *unstructured.Unstructured) []common.GKNN { return []common.GKNN{{ Group: common.NamespaceGK.Group, Kind: common.NamespaceGK.Kind, Name: u.GetNamespace(), }} }, } // HTTPRouteNamespace returns the Namespace for the HTTPRoute. HTTPRouteNamespace = &topology.Relation{ From: common.HTTPRouteGK, To: common.NamespaceGK, Name: "Namespace", NeighborFunc: func(u *unstructured.Unstructured) []common.GKNN { return []common.GKNN{{ Group: common.NamespaceGK.Group, Kind: common.NamespaceGK.Kind, Name: u.GetNamespace(), }} }, } // BackendNamespace returns the Namespace for the Gateway. BackendNamespace = &topology.Relation{ From: common.ServiceGK, To: common.NamespaceGK, Name: "Namespace", NeighborFunc: func(u *unstructured.Unstructured) []common.GKNN { return []common.GKNN{{ Group: common.NamespaceGK.Group, Kind: common.NamespaceGK.Kind, Name: u.GetNamespace(), }} }, } )
Functions ¶
func BackendNode ¶
func GatewayClassNode ¶
func GatewayNode ¶
func HTTPRouteNode ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.