mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-11-04 00:10:57 +00:00 
			
		
		
		
	Fix: return all http routes of a namespace (k8s) (#4865)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									d55a5e5efe
								
							
						
					
					
						commit
						99cde187d8
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
import { CustomObjectsApi, CoreV1Api } from "@kubernetes/client-node";
 | 
					import { CoreV1Api, CustomObjectsApi } from "@kubernetes/client-node";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { getKubernetes, getKubeConfig, HTTPROUTE_API_GROUP, HTTPROUTE_API_VERSION } from "utils/config/kubernetes";
 | 
					import { getKubeConfig, getKubernetes, HTTPROUTE_API_GROUP, HTTPROUTE_API_VERSION } from "utils/config/kubernetes";
 | 
				
			||||||
import createLogger from "utils/logger";
 | 
					import createLogger from "utils/logger";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const logger = createLogger("httproute-list");
 | 
					const logger = createLogger("httproute-list");
 | 
				
			||||||
@ -14,7 +14,7 @@ export default async function listHttpRoute() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (gateway) {
 | 
					  if (gateway) {
 | 
				
			||||||
    // httproutes
 | 
					    // httproutes
 | 
				
			||||||
    const getHttpRoute = async (namespace) =>
 | 
					    const getHttpRoutes = async (namespace) =>
 | 
				
			||||||
      crd
 | 
					      crd
 | 
				
			||||||
        .listNamespacedCustomObject({
 | 
					        .listNamespacedCustomObject({
 | 
				
			||||||
          group: HTTPROUTE_API_GROUP,
 | 
					          group: HTTPROUTE_API_GROUP,
 | 
				
			||||||
@ -23,8 +23,7 @@ export default async function listHttpRoute() {
 | 
				
			|||||||
          plural: "httproutes",
 | 
					          plural: "httproutes",
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
        .then((response) => {
 | 
					        .then((response) => {
 | 
				
			||||||
          const [httpRoute] = response.items;
 | 
					          return response.items;
 | 
				
			||||||
          return httpRoute;
 | 
					 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
        .catch((error) => {
 | 
					        .catch((error) => {
 | 
				
			||||||
          logger.error("Error getting httproutes: %d %s %s", error.statusCode, error.body, error.response);
 | 
					          logger.error("Error getting httproutes: %d %s %s", error.statusCode, error.body, error.response);
 | 
				
			||||||
@ -44,12 +43,12 @@ export default async function listHttpRoute() {
 | 
				
			|||||||
    if (namespaces) {
 | 
					    if (namespaces) {
 | 
				
			||||||
      const httpRouteListUnfiltered = await Promise.all(
 | 
					      const httpRouteListUnfiltered = await Promise.all(
 | 
				
			||||||
        namespaces.map(async (namespace) => {
 | 
					        namespaces.map(async (namespace) => {
 | 
				
			||||||
          const httpRoute = await getHttpRoute(namespace);
 | 
					          const httpRoutes = await getHttpRoutes(namespace);
 | 
				
			||||||
          return httpRoute;
 | 
					          return httpRoutes;
 | 
				
			||||||
        }),
 | 
					        }),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      httpRouteList = httpRouteListUnfiltered.filter((httpRoute) => httpRoute !== undefined);
 | 
					      httpRouteList = httpRouteListUnfiltered.flat().filter((httpRoute) => httpRoute);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return httpRouteList;
 | 
					  return httpRouteList;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user