Applied ESLint rules to code. Plus minor rewrite.
This commit is contained in:
parent
60eee26ac4
commit
ac997ea841
@ -73,8 +73,28 @@ function getUrlFromIngress(ingress) {
|
||||
}
|
||||
|
||||
async function getHttpRouteList() {
|
||||
const httpRouteList = [];
|
||||
|
||||
// httproutes
|
||||
const getHttpRoute = (async (namespace) =>
|
||||
crd
|
||||
.listNamespacedCustomObject(
|
||||
apiGroup,
|
||||
version,
|
||||
namespace,
|
||||
"httproutes"
|
||||
)
|
||||
.then((response) => {
|
||||
const [httpRoute] = response.body.items;
|
||||
return httpRoute;
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error("Error getting httproutes: %d %s %s", error.statusCode, error.body, error.response);
|
||||
logger.debug(error);
|
||||
return null;
|
||||
})
|
||||
)
|
||||
|
||||
// namespaces
|
||||
const namespaces = await core
|
||||
.listNamespace()
|
||||
.then((response) => response.body.items.map((ns) => ns.metadata.name))
|
||||
@ -84,19 +104,20 @@ async function getHttpRouteList() {
|
||||
return null;
|
||||
});
|
||||
|
||||
let httpRouteList = [];
|
||||
if (namespaces) {
|
||||
// Iterate over each namespace
|
||||
for (const namespace of namespaces) {
|
||||
try {
|
||||
// Fetch the httproute from one namespaces
|
||||
const httpRoute = await crd.listNamespacedCustomObject(apiGroup, version, namespace, "httproutes");
|
||||
if (httpRoute.body.items.length !== 0) {
|
||||
httpRouteList.push(httpRoute.body.items[0]);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error fetching httproutes objects in namespace "${namespace}":`, err.body || err.message);
|
||||
}
|
||||
}
|
||||
|
||||
const httpRouteListUnfiltered = await Promise.all(
|
||||
namespaces
|
||||
.map( async(namespace) => {
|
||||
const httpRoute = await getHttpRoute(namespace);
|
||||
return httpRoute;
|
||||
})
|
||||
)
|
||||
|
||||
httpRouteList = httpRouteListUnfiltered
|
||||
.filter((httpRoute) => httpRoute !== undefined)
|
||||
|
||||
}
|
||||
return httpRouteList;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user