Override config directory with env var.

Until this change, the config directory was assumed
to be located at '/config'. This patch retains that
default behaviour, but enables users/devs to override
that behaviour by setting the HOMEPAGE_CONFIG_DIR
variable.
This commit is contained in:
Jon Seager 2023-07-10 15:44:43 +01:00
parent 9c0bd8b07a
commit ca396ce96b
No known key found for this signature in database
8 changed files with 28 additions and 24 deletions

View file

@ -7,7 +7,7 @@ import * as shvl from "shvl";
import { CustomObjectsApi, NetworkingV1Api } from "@kubernetes/client-node";
import createLogger from "utils/logger";
import checkAndCopyConfig, { substituteEnvironmentVars } from "utils/config/config";
import checkAndCopyConfig, { CONF_DIR, substituteEnvironmentVars } from "utils/config/config";
import getDockerArguments from "utils/config/docker";
import getKubeConfig from "utils/config/kubernetes";
@ -17,7 +17,7 @@ const logger = createLogger("service-helpers");
export async function servicesFromConfig() {
checkAndCopyConfig("services.yaml");
const servicesYaml = path.join(process.cwd(), "config", "services.yaml");
const servicesYaml = path.join(CONF_DIR, "services.yaml");
const rawFileContents = await fs.readFile(servicesYaml, "utf8");
const fileContents = substituteEnvironmentVars(rawFileContents);
const services = yaml.load(fileContents);
@ -51,7 +51,7 @@ export async function servicesFromConfig() {
export async function servicesFromDocker() {
checkAndCopyConfig("docker.yaml");
const dockerYaml = path.join(process.cwd(), "config", "docker.yaml");
const dockerYaml = path.join(CONF_DIR, "docker.yaml");
const rawDockerFileContents = await fs.readFile(dockerYaml, "utf8");
const dockerFileContents = substituteEnvironmentVars(rawDockerFileContents);
const servers = yaml.load(dockerFileContents);