Moved crd checker to kubernetes-routes
This commit is contained in:
parent
9367fd761b
commit
d65cb638be
@ -151,26 +151,6 @@ export async function servicesFromDocker() {
|
||||
return mappedServiceGroups;
|
||||
}
|
||||
|
||||
export async function checkCRD(kc, name) {
|
||||
const apiExtensions = kc.makeApiClient(ApiextensionsV1Api);
|
||||
const exist = await apiExtensions
|
||||
.readCustomResourceDefinitionStatus(name)
|
||||
.then(() => true)
|
||||
.catch(async (error) => {
|
||||
if (error.statusCode === 403) {
|
||||
logger.error(
|
||||
"Error checking if CRD %s exists. Make sure to add the following permission to your RBAC: %d %s %s",
|
||||
name,
|
||||
error.statusCode,
|
||||
error.body.message,
|
||||
);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
export async function servicesFromKubernetes() {
|
||||
const ANNOTATION_BASE = "gethomepage.dev";
|
||||
const ANNOTATION_WIDGET_BASE = `${ANNOTATION_BASE}/widget.`;
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
|
||||
|
||||
import { CustomObjectsApi, NetworkingV1Api, CoreV1Api } from "@kubernetes/client-node";
|
||||
import { CustomObjectsApi, NetworkingV1Api, CoreV1Api, ApiextensionsV1Api } from "@kubernetes/client-node";
|
||||
import getKubeArguments from "utils/config/kubernetes";
|
||||
import createLogger from "utils/logger";
|
||||
|
||||
const logger = createLogger("service-helpers");
|
||||
|
||||
const kubeArguments = getKubeArguments();
|
||||
const kc = kubeArguments.config;
|
||||
@ -15,6 +18,27 @@ let networking;
|
||||
let routingType;
|
||||
let traefik;
|
||||
|
||||
|
||||
export async function checkCRD(kc, name) {
|
||||
const apiExtensions = kc.makeApiClient(ApiextensionsV1Api);
|
||||
const exist = await apiExtensions
|
||||
.readCustomResourceDefinitionStatus(name)
|
||||
.then(() => true)
|
||||
.catch(async (error) => {
|
||||
if (error.statusCode === 403) {
|
||||
logger.error(
|
||||
"Error checking if CRD %s exists. Make sure to add the following permission to your RBAC: %d %s %s",
|
||||
name,
|
||||
error.statusCode,
|
||||
error.body.message,
|
||||
);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
const getSchemaFromGateway = async (gatewayRef) => {
|
||||
try {
|
||||
const gateway = await crd.getNamespacedCustomObject(apiGroup, version, gatewayRef.namespace,"gateways",gatewayRef.name);
|
||||
@ -57,9 +81,9 @@ async function getHttpRouteList(){
|
||||
for (const namespace of namespaces) {
|
||||
try {
|
||||
// Fetch the httproute from one namespaces
|
||||
const customObject = await crd.listNamespacedCustomObject(apiGroup,version,namespace,'httproutes');
|
||||
if (customObject.body.items.length !== 0){
|
||||
httpRouteList.push(customObject.body.items[0]);
|
||||
const httpRoute = await crd.listNamespacedCustomObject(apiGroup,version,namespace,'httproutes');
|
||||
if (httpRoute.body.items.length !== 0){
|
||||
httpRouteList.push(httpRoute.body.items[0]);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
@ -175,6 +199,5 @@ export async function getUrlSchema(route) {
|
||||
default:
|
||||
urlSchema = getUrlFromIngress(route);
|
||||
}
|
||||
|
||||
return urlSchema;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user