feat: add support for attaching secrets to process env

This commit is contained in:
Daniel Hougaard
2025-07-28 15:30:16 +04:00
parent a75cdfb54e
commit 95ec789781
2 changed files with 11 additions and 1 deletions

View File

@@ -108,6 +108,7 @@ export type ListSecretsOptions = {
environment: string; environment: string;
projectId: string; projectId: string;
expandSecretReferences?: boolean; expandSecretReferences?: boolean;
attachToProcessEnv?: boolean;
includeImports?: boolean; includeImports?: boolean;
recursive?: boolean; recursive?: boolean;
secretPath?: string; secretPath?: string;

View File

@@ -16,7 +16,7 @@ export default class SecretsClient {
listSecrets = async (options: ListSecretsOptions) => { listSecrets = async (options: ListSecretsOptions) => {
try { try {
return await this.apiClient.listSecrets({ const res = await this.apiClient.listSecrets({
workspaceId: options.projectId, workspaceId: options.projectId,
environment: options.environment, environment: options.environment,
expandSecretReferences: convertBool( expandSecretReferences: convertBool(
@@ -28,6 +28,15 @@ export default class SecretsClient {
tagSlugs: options.tagSlugs ? options.tagSlugs.join(",") : undefined, tagSlugs: options.tagSlugs ? options.tagSlugs.join(",") : undefined,
viewSecretValue: convertBool(options.viewSecretValue ?? true), viewSecretValue: convertBool(options.viewSecretValue ?? true),
}); });
if (options.attachToProcessEnv) {
for (const secret of res.secrets) {
process.env[secret.secretKey] = secret.secretValue;
}
}
return res;
} catch (err) { } catch (err) {
throw newInfisicalError(err); throw newInfisicalError(err);
} }