mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Moved checkCRD to config/kubernetes.js
This commit is contained in:
@@ -2,7 +2,7 @@ import path from "path";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
import yaml from "js-yaml";
|
||||
import { KubeConfig } from "@kubernetes/client-node";
|
||||
import { KubeConfig,ApiextensionsV1Api } from "@kubernetes/client-node";
|
||||
|
||||
import checkAndCopyConfig, { CONF_DIR, substituteEnvironmentVars } from "utils/config/config";
|
||||
|
||||
@@ -53,3 +53,24 @@ export default function getKubeArguments() {
|
||||
|
||||
return kubeData;
|
||||
}
|
||||
|
||||
|
||||
export async function checkCRD(name,kc,logger) {
|
||||
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;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CustomObjectsApi, NetworkingV1Api, CoreV1Api, ApiextensionsV1Api } from "@kubernetes/client-node";
|
||||
import { CustomObjectsApi, NetworkingV1Api, CoreV1Api } from "@kubernetes/client-node";
|
||||
|
||||
import getKubeArguments from "utils/config/kubernetes";
|
||||
import createLogger from "utils/logger";
|
||||
@@ -17,26 +17,6 @@ let networking;
|
||||
let routingType;
|
||||
let traefik;
|
||||
|
||||
export async function checkCRD(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) => {
|
||||
const schema = await crd
|
||||
.getNamespacedCustomObject(apiGroup, version, gatewayRef.namespace, "gateways", gatewayRef.name)
|
||||
@@ -123,8 +103,8 @@ async function getIngressList(ANNOTATION_BASE) {
|
||||
});
|
||||
|
||||
if (traefik) {
|
||||
const traefikContainoExists = await checkCRD("ingressroutes.traefik.containo.us");
|
||||
const traefikExists = await checkCRD("ingressroutes.traefik.io");
|
||||
const traefikContainoExists = await checkCRD("ingressroutes.traefik.containo.us",kc,logger);
|
||||
const traefikExists = await checkCRD("ingressroutes.traefik.io",kc,logger);
|
||||
|
||||
const traefikIngressListContaino = await crd
|
||||
.listClusterCustomObject("traefik.containo.us", "v1alpha1", "ingressroutes")
|
||||
|
||||
Reference in New Issue
Block a user