mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Fix env file config loading (no-changelog) (#5339)
* fix(core): Do not trim config values read from files (no-changelog) * do not use config.load. it does not work
This commit is contained in:
parent
e58bc41d24
commit
93a2dac063
|
@ -44,33 +44,27 @@ if (!inE2ETests && !inTest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overwrite config from files defined in "_FILE" environment variables
|
// Overwrite config from files defined in "_FILE" environment variables
|
||||||
const overwrites = Object.entries(process.env).reduce<Record<string, string>>(
|
Object.entries(process.env).forEach(([envName, fileName]) => {
|
||||||
(acc, [envName, fileName]) => {
|
if (envName.endsWith('_FILE') && fileName) {
|
||||||
if (envName.endsWith('_FILE') && fileName) {
|
const configEnvName = envName.replace(/_FILE$/, '');
|
||||||
const configEnvName = envName.replace(/_FILE$/, '');
|
// @ts-ignore
|
||||||
// @ts-ignore
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
const key = config._env[configEnvName]?.[0] as string;
|
||||||
const key = config._env[configEnvName]?.[0] as string;
|
if (key) {
|
||||||
if (key) {
|
let value: string;
|
||||||
let value: string;
|
try {
|
||||||
try {
|
value = readFileSync(fileName, 'utf8');
|
||||||
value = readFileSync(fileName, 'utf8').trim();
|
} catch (error) {
|
||||||
} catch (error) {
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
if (error.code === 'ENOENT') {
|
||||||
if (error.code === 'ENOENT') {
|
throw new Error(`The file "${fileName}" could not be found.`);
|
||||||
throw new Error(`The file "${fileName}" could not be found.`);
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
console.debug('Loading config overwrite', { fileName });
|
throw error;
|
||||||
acc[key] = value;
|
|
||||||
}
|
}
|
||||||
|
config.set(key, value);
|
||||||
}
|
}
|
||||||
return acc;
|
}
|
||||||
},
|
});
|
||||||
{},
|
|
||||||
);
|
|
||||||
config.load(overwrites);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.validate({
|
config.validate({
|
||||||
|
|
Loading…
Reference in a new issue