prioritize org over user secrets
This commit is contained in:
parent
35584f2e26
commit
dcf6c10ffb
3 changed files with 16 additions and 19 deletions
|
|
@ -36,7 +36,13 @@ export async function resolveFQSN(
|
|||
const reversedSlugs = [...fqsn.packageSlugs].reverse();
|
||||
|
||||
const locationsToLook: SecretLocation[] = [
|
||||
// Packages first
|
||||
// Organization first
|
||||
...reversedSlugs.map((slug) => ({
|
||||
secretType: SecretType.Organization as const,
|
||||
orgSlug: slug.ownerSlug,
|
||||
secretName: fqsn.secretName,
|
||||
})),
|
||||
// Then packages
|
||||
...reversedSlugs.map((slug) => ({
|
||||
secretType: SecretType.Package as const,
|
||||
packageSlug: slug,
|
||||
|
|
@ -48,12 +54,6 @@ export async function resolveFQSN(
|
|||
userSlug: currentUserSlug,
|
||||
secretName: fqsn.secretName,
|
||||
},
|
||||
// Then organization
|
||||
...reversedSlugs.map((slug) => ({
|
||||
secretType: SecretType.Organization as const,
|
||||
orgSlug: slug.ownerSlug,
|
||||
secretName: fqsn.secretName,
|
||||
})),
|
||||
];
|
||||
|
||||
// Then try to get the secret from each location
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import {
|
|||
|
||||
export async function clientRender(
|
||||
unrolledConfigContent: string,
|
||||
secretStore: SecretStore,
|
||||
clientSecretStore: SecretStore,
|
||||
platformClient?: PlatformClient,
|
||||
): Promise<AssistantUnrolled> {
|
||||
// 1. First we need to get a list of all the FQSNs that are required to render the config
|
||||
|
|
@ -23,16 +23,9 @@ export async function clientRender(
|
|||
// 2. Then, we will check which of the secrets are found in the local personal secret store. Here we’re checking for anything that matches the last part of the FQSN, not worrying about the owner/package/owner/package slugs
|
||||
const secretsTemplateData: Record<string, string> = {};
|
||||
|
||||
const unresolvedFQSNs: FQSN[] = [];
|
||||
for (const secret of secrets) {
|
||||
const fqsn = decodeFQSN(secret.replace("secrets.", ""));
|
||||
const secretValue = await secretStore.get(fqsn.secretName);
|
||||
if (secretValue) {
|
||||
secretsTemplateData[secret] = secretValue;
|
||||
} else {
|
||||
unresolvedFQSNs.push(fqsn);
|
||||
}
|
||||
}
|
||||
const unresolvedFQSNs: FQSN[] = secrets.map((secret) => {
|
||||
return decodeFQSN(secret.replace("secrets.", ""));
|
||||
});
|
||||
|
||||
// Don't use platform client in local mode
|
||||
if (platformClient) {
|
||||
|
|
@ -46,7 +39,9 @@ export async function clientRender(
|
|||
}
|
||||
|
||||
if ("value" in secretResult) {
|
||||
secretStore.set(secretResult.fqsn.secretName, secretResult.value);
|
||||
// clientSecretStore.set(secretResult.fqsn.secretName, secretResult.value);
|
||||
// const secretValue = await clientSecretStore.get(fqsn.secretName);
|
||||
secretsTemplateData[encodeFQSN(secretResult.fqsn)] = secretResult.value;
|
||||
}
|
||||
|
||||
secretsTemplateData["secrets." + encodeFQSN(secretResult.fqsn)] =
|
||||
|
|
|
|||
|
|
@ -176,4 +176,6 @@ describe("E2E Scenarios", () => {
|
|||
);
|
||||
expect(geminiSecretValue2).toBe("gemini-api-key");
|
||||
});
|
||||
|
||||
it.skip("should prioritize org over user / package secrets", () => {});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue