diff --git a/packages/config-yaml/src/interfaces/index.ts b/packages/config-yaml/src/interfaces/index.ts index 3bbd17d92..f8db8b1d4 100644 --- a/packages/config-yaml/src/interfaces/index.ts +++ b/packages/config-yaml/src/interfaces/index.ts @@ -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 diff --git a/packages/config-yaml/src/load/clientRender.ts b/packages/config-yaml/src/load/clientRender.ts index 63bca7e0e..d55d694af 100644 --- a/packages/config-yaml/src/load/clientRender.ts +++ b/packages/config-yaml/src/load/clientRender.ts @@ -14,7 +14,7 @@ import { export async function clientRender( unrolledConfigContent: string, - secretStore: SecretStore, + clientSecretStore: SecretStore, platformClient?: PlatformClient, ): Promise { // 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 = {}; - 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)] = diff --git a/packages/config-yaml/test/index.test.ts b/packages/config-yaml/test/index.test.ts index 8bba163ce..9573b8ae3 100644 --- a/packages/config-yaml/test/index.test.ts +++ b/packages/config-yaml/test/index.test.ts @@ -176,4 +176,6 @@ describe("E2E Scenarios", () => { ); expect(geminiSecretValue2).toBe("gemini-api-key"); }); + + it.skip("should prioritize org over user / package secrets", () => {}); });