Enhance environment variable handling in processTemplate: support boolean and number types in env configuration, with tests for both array and object formats.

This commit is contained in:
Mauricio Siu
2025-03-30 01:29:23 -06:00
parent 4eaf8fee0f
commit 84f5627471
2 changed files with 56 additions and 2 deletions

View File

@@ -45,7 +45,9 @@ export interface CompleteTemplate {
variables: Record<string, string>;
config: {
domains: DomainConfig[];
env: Record<string, string> | string[];
env:
| Record<string, string | boolean | number>
| (string | Record<string, string | boolean | number>)[];
mounts?: MountConfig[];
};
}
@@ -200,7 +202,16 @@ export function processEnvVars(
if (typeof env === "string") {
return processValue(env, variables, schema);
}
return env;
// Si es un objeto, asumimos que es un par clave-valor
if (typeof env === "object" && env !== null) {
const keys = Object.keys(env);
if (keys.length > 0) {
const key = keys[0];
return `${key}=${env[key as keyof typeof env]}`;
}
}
// Para valores primitivos (boolean, number)
return String(env);
});
}