Merge pull request #25 from Infisical/daniel/fix-imports-2
fix: broken imports and attach to env with imports
This commit is contained in:
@@ -36,7 +36,7 @@ export interface ListSecretsRequest {
|
|||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
expandSecretReferences?: string;
|
expandSecretReferences?: string;
|
||||||
includeImports?: string;
|
include_imports?: string;
|
||||||
recursive?: string;
|
recursive?: string;
|
||||||
secretPath?: string;
|
secretPath?: string;
|
||||||
tagSlugs?: string;
|
tagSlugs?: string;
|
||||||
|
|||||||
@@ -19,24 +19,32 @@ export default class SecretsClient {
|
|||||||
const res = 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(defaultBoolean(options.expandSecretReferences, true)),
|
||||||
defaultBoolean(options.expandSecretReferences, true)
|
include_imports: convertBool(options.includeImports),
|
||||||
),
|
|
||||||
includeImports: convertBool(options.includeImports),
|
|
||||||
recursive: convertBool(options.recursive),
|
recursive: convertBool(options.recursive),
|
||||||
secretPath: options.secretPath,
|
secretPath: options.secretPath,
|
||||||
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) {
|
if (options.attachToProcessEnv) {
|
||||||
for (const secret of res.secrets) {
|
let includedSecrets = res.secrets;
|
||||||
|
if (res.imports?.length) {
|
||||||
|
for (const imp of res.imports) {
|
||||||
|
for (const importSecret of imp.secrets) {
|
||||||
|
if (!includedSecrets.find(includedSecret => includedSecret.secretKey === importSecret.secretKey)) {
|
||||||
|
includedSecrets.push(importSecret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const secret of includedSecrets) {
|
||||||
process.env[secret.secretKey] = secret.secretValue;
|
process.env[secret.secretKey] = secret.secretValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw newInfisicalError(err);
|
throw newInfisicalError(err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user