mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Applied prettier to code
This commit is contained in:
@@ -7,36 +7,31 @@ import { KubeConfig } from "@kubernetes/client-node";
|
||||
import checkAndCopyConfig, { CONF_DIR, substituteEnvironmentVars } from "utils/config/config";
|
||||
|
||||
const extractKubeData = (config) => {
|
||||
|
||||
//kubeconfig
|
||||
const kc = new KubeConfig();
|
||||
kc.loadFromCluster()
|
||||
kc.loadFromCluster();
|
||||
|
||||
//route
|
||||
let route="ingress";
|
||||
if (config?.route=="gateway"){
|
||||
route="gateway";
|
||||
let route = "ingress";
|
||||
if (config?.route == "gateway") {
|
||||
route = "gateway";
|
||||
}
|
||||
|
||||
//traefik
|
||||
let traefik=true;
|
||||
if (config?.traefik=="disable"){
|
||||
traefik=false;
|
||||
let traefik = true;
|
||||
if (config?.traefik == "disable") {
|
||||
traefik = false;
|
||||
}
|
||||
|
||||
//traefik
|
||||
let metrics=true;
|
||||
if (config?.metrics=="disable"){
|
||||
metrics=false;
|
||||
let metrics = true;
|
||||
if (config?.metrics == "disable") {
|
||||
metrics = false;
|
||||
}
|
||||
|
||||
//return
|
||||
return {"config":kc,
|
||||
"route":route,
|
||||
"traefik":traefik,
|
||||
"metrics":metrics
|
||||
};
|
||||
}
|
||||
return { config: kc, route: route, traefik: traefik, metrics: metrics };
|
||||
};
|
||||
|
||||
export default function getKubeArguments() {
|
||||
checkAndCopyConfig("kubernetes.yaml");
|
||||
@@ -56,7 +51,7 @@ export default function getKubeArguments() {
|
||||
break;
|
||||
case "disabled":
|
||||
default:
|
||||
kubeData=null;
|
||||
kubeData = null;
|
||||
}
|
||||
|
||||
return kubeData;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ApiextensionsV1Api } from "@kubernetes/client-node";
|
||||
import createLogger from "utils/logger";
|
||||
import checkAndCopyConfig, { CONF_DIR, getSettings, substituteEnvironmentVars } from "utils/config/config";
|
||||
import getDockerArguments from "utils/config/docker";
|
||||
import {getUrlSchema,getRouteList} from "utils/kubernetes/kubernetes-routes";
|
||||
import { getUrlSchema, getRouteList } from "utils/kubernetes/kubernetes-routes";
|
||||
import * as shvl from "utils/config/shvl";
|
||||
|
||||
const logger = createLogger("service-helpers");
|
||||
@@ -160,67 +160,68 @@ export async function servicesFromKubernetes() {
|
||||
|
||||
try {
|
||||
const routeList = await getRouteList();
|
||||
|
||||
|
||||
if (!routeList) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const services = await Promise.all(routeList
|
||||
.filter(
|
||||
(route) =>
|
||||
route.metadata.annotations &&
|
||||
route.metadata.annotations[`${ANNOTATION_BASE}/enabled`] === "true" &&
|
||||
(!route.metadata.annotations[`${ANNOTATION_BASE}/instance`] ||
|
||||
route.metadata.annotations[`${ANNOTATION_BASE}/instance`] === instanceName ||
|
||||
`${ANNOTATION_BASE}/instance.${instanceName}` in route.metadata.annotations),
|
||||
)
|
||||
.map( async (route) => {
|
||||
let constructedService = {
|
||||
app: route.metadata.annotations[`${ANNOTATION_BASE}/app`] || route.metadata.name,
|
||||
namespace: route.metadata.namespace,
|
||||
href: route.metadata.annotations[`${ANNOTATION_BASE}/href`] || await getUrlSchema(route),
|
||||
name: route.metadata.annotations[`${ANNOTATION_BASE}/name`] || route.metadata.name,
|
||||
group: route.metadata.annotations[`${ANNOTATION_BASE}/group`] || "Kubernetes",
|
||||
weight: route.metadata.annotations[`${ANNOTATION_BASE}/weight`] || "0",
|
||||
icon: route.metadata.annotations[`${ANNOTATION_BASE}/icon`] || "",
|
||||
description: route.metadata.annotations[`${ANNOTATION_BASE}/description`] || "",
|
||||
external: false,
|
||||
type: "service",
|
||||
};
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/external`]) {
|
||||
constructedService.external =
|
||||
String(route.metadata.annotations[`${ANNOTATION_BASE}/external`]).toLowerCase() === "true";
|
||||
}
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/pod-selector`] !== undefined) {
|
||||
constructedService.podSelector = route.metadata.annotations[`${ANNOTATION_BASE}/pod-selector`];
|
||||
}
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/ping`]) {
|
||||
constructedService.ping = route.metadata.annotations[`${ANNOTATION_BASE}/ping`];
|
||||
}
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/siteMonitor`]) {
|
||||
constructedService.siteMonitor = route.metadata.annotations[`${ANNOTATION_BASE}/siteMonitor`];
|
||||
}
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/statusStyle`]) {
|
||||
constructedService.statusStyle = route.metadata.annotations[`${ANNOTATION_BASE}/statusStyle`];
|
||||
}
|
||||
Object.keys(route.metadata.annotations).forEach((annotation) => {
|
||||
if (annotation.startsWith(ANNOTATION_WIDGET_BASE)) {
|
||||
shvl.set(
|
||||
constructedService,
|
||||
annotation.replace(`${ANNOTATION_BASE}/`, ""),
|
||||
route.metadata.annotations[annotation],
|
||||
);
|
||||
const services = await Promise.all(
|
||||
routeList
|
||||
.filter(
|
||||
(route) =>
|
||||
route.metadata.annotations &&
|
||||
route.metadata.annotations[`${ANNOTATION_BASE}/enabled`] === "true" &&
|
||||
(!route.metadata.annotations[`${ANNOTATION_BASE}/instance`] ||
|
||||
route.metadata.annotations[`${ANNOTATION_BASE}/instance`] === instanceName ||
|
||||
`${ANNOTATION_BASE}/instance.${instanceName}` in route.metadata.annotations),
|
||||
)
|
||||
.map(async (route) => {
|
||||
let constructedService = {
|
||||
app: route.metadata.annotations[`${ANNOTATION_BASE}/app`] || route.metadata.name,
|
||||
namespace: route.metadata.namespace,
|
||||
href: route.metadata.annotations[`${ANNOTATION_BASE}/href`] || (await getUrlSchema(route)),
|
||||
name: route.metadata.annotations[`${ANNOTATION_BASE}/name`] || route.metadata.name,
|
||||
group: route.metadata.annotations[`${ANNOTATION_BASE}/group`] || "Kubernetes",
|
||||
weight: route.metadata.annotations[`${ANNOTATION_BASE}/weight`] || "0",
|
||||
icon: route.metadata.annotations[`${ANNOTATION_BASE}/icon`] || "",
|
||||
description: route.metadata.annotations[`${ANNOTATION_BASE}/description`] || "",
|
||||
external: false,
|
||||
type: "service",
|
||||
};
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/external`]) {
|
||||
constructedService.external =
|
||||
String(route.metadata.annotations[`${ANNOTATION_BASE}/external`]).toLowerCase() === "true";
|
||||
}
|
||||
});
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/pod-selector`] !== undefined) {
|
||||
constructedService.podSelector = route.metadata.annotations[`${ANNOTATION_BASE}/pod-selector`];
|
||||
}
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/ping`]) {
|
||||
constructedService.ping = route.metadata.annotations[`${ANNOTATION_BASE}/ping`];
|
||||
}
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/siteMonitor`]) {
|
||||
constructedService.siteMonitor = route.metadata.annotations[`${ANNOTATION_BASE}/siteMonitor`];
|
||||
}
|
||||
if (route.metadata.annotations[`${ANNOTATION_BASE}/statusStyle`]) {
|
||||
constructedService.statusStyle = route.metadata.annotations[`${ANNOTATION_BASE}/statusStyle`];
|
||||
}
|
||||
Object.keys(route.metadata.annotations).forEach((annotation) => {
|
||||
if (annotation.startsWith(ANNOTATION_WIDGET_BASE)) {
|
||||
shvl.set(
|
||||
constructedService,
|
||||
annotation.replace(`${ANNOTATION_BASE}/`, ""),
|
||||
route.metadata.annotations[annotation],
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
constructedService = JSON.parse(substituteEnvironmentVars(JSON.stringify(constructedService)));
|
||||
} catch (e) {
|
||||
logger.error("Error attempting k8s environment variable substitution.");
|
||||
logger.debug(e);
|
||||
}
|
||||
return constructedService;
|
||||
})
|
||||
try {
|
||||
constructedService = JSON.parse(substituteEnvironmentVars(JSON.stringify(constructedService)));
|
||||
} catch (e) {
|
||||
logger.error("Error attempting k8s environment variable substitution.");
|
||||
logger.debug(e);
|
||||
}
|
||||
return constructedService;
|
||||
}),
|
||||
);
|
||||
|
||||
const mappedServiceGroups = [];
|
||||
|
||||
Reference in New Issue
Block a user