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:
James Wynn 2023-02-23 08:50:25 -06:00
parent b65f6fca19
commit e0f1aae4d5
6 changed files with 38 additions and 13 deletions

View file

@ -4,7 +4,7 @@ import path from "path";
import yaml from "js-yaml";
import checkAndCopyConfig, { getSettings } from "utils/config/config";
import checkAndCopyConfig, { getSettings, substituteEnvironmentVars } from "utils/config/config";
import {
servicesFromConfig,
servicesFromDocker,
@ -28,7 +28,8 @@ export async function bookmarksResponse() {
checkAndCopyConfig("bookmarks.yaml");
const bookmarksYaml = path.join(process.cwd(), "config", "bookmarks.yaml");
const fileContents = await fs.readFile(bookmarksYaml, "utf8");
const rawFileContents = await fs.readFile(bookmarksYaml, "utf8");
const fileContents = substituteEnvironmentVars(rawFileContents);
const bookmarks = yaml.load(fileContents);
if (!bookmarks) return [];