mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-06 21:57:48 +01:00
* Only environment variables starting with HOMEPAGE_VAR_ and HOMEPAGE_FILE_
are supported
* The value of env var HOMEPAGE_VAR_XXX will replace {{HOMEPAGE_VAR_XXX}}
in any config
* The value of env var HOMEPAGE_FILE_XXX must be a file path, the contents
of which will be used to replace {{HOMEPAGE_FILE_XXX}} in any config
* If a substituted value contains a variable reference it may also be
replaced, but the behavior is non-deterministic
32 lines
804 B
JavaScript
32 lines
804 B
JavaScript
import path from "path";
|
|
import { readFileSync } from "fs";
|
|
|
|
import yaml from "js-yaml";
|
|
import { KubeConfig } from "@kubernetes/client-node";
|
|
|
|
import checkAndCopyConfig, { substituteEnvironmentVars } from "utils/config/config";
|
|
|
|
export default function getKubeConfig() {
|
|
checkAndCopyConfig("kubernetes.yaml");
|
|
|
|
const configFile = path.join(process.cwd(), "config", "kubernetes.yaml");
|
|
const rawConfigData = readFileSync(configFile, "utf8");
|
|
const configData = substituteEnvironmentVars(rawConfigData);
|
|
const config = yaml.load(configData);
|
|
const kc = new KubeConfig();
|
|
|
|
switch (config?.mode) {
|
|
case 'cluster':
|
|
kc.loadFromCluster();
|
|
break;
|
|
case 'default':
|
|
kc.loadFromDefault();
|
|
break;
|
|
case 'disabled':
|
|
default:
|
|
return null;
|
|
}
|
|
|
|
return kc;
|
|
}
|