mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Added support for environment variable substitution
* 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
This commit is contained in:
@@ -7,17 +7,19 @@ import * as shvl from "shvl";
|
||||
import { NetworkingV1Api } from "@kubernetes/client-node";
|
||||
|
||||
import createLogger from "utils/logger";
|
||||
import checkAndCopyConfig from "utils/config/config";
|
||||
import checkAndCopyConfig, { substituteEnvironmentVars } from "utils/config/config";
|
||||
import getDockerArguments from "utils/config/docker";
|
||||
import getKubeConfig from "utils/config/kubernetes";
|
||||
|
||||
const logger = createLogger("service-helpers");
|
||||
|
||||
|
||||
export async function servicesFromConfig() {
|
||||
checkAndCopyConfig("services.yaml");
|
||||
|
||||
const servicesYaml = path.join(process.cwd(), "config", "services.yaml");
|
||||
const fileContents = await fs.readFile(servicesYaml, "utf8");
|
||||
const rawFileContents = await fs.readFile(servicesYaml, "utf8");
|
||||
const fileContents = substituteEnvironmentVars(rawFileContents);
|
||||
const services = yaml.load(fileContents);
|
||||
|
||||
if (!services) {
|
||||
@@ -49,7 +51,8 @@ export async function servicesFromDocker() {
|
||||
checkAndCopyConfig("docker.yaml");
|
||||
|
||||
const dockerYaml = path.join(process.cwd(), "config", "docker.yaml");
|
||||
const dockerFileContents = await fs.readFile(dockerYaml, "utf8");
|
||||
const rawDockerFileContents = await fs.readFile(dockerYaml, "utf8");
|
||||
const dockerFileContents = substituteEnvironmentVars(rawDockerFileContents);
|
||||
const servers = yaml.load(dockerFileContents);
|
||||
|
||||
if (!servers) {
|
||||
|
||||
Reference in New Issue
Block a user