feat: add support for attaching secrets to process env
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user