From 2ff418f28a66dd71cd80701e95ec26db12875f15 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Wed, 8 Oct 2025 12:54:49 +0100 Subject: [PATCH] Parse `language` before calling `getCredentials` --- lib/start-proxy-action.js | 7 ++++--- src/start-proxy-action.ts | 5 ++++- src/start-proxy.test.ts | 4 ++-- src/start-proxy.ts | 3 +-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 8eb317706..7ac17694f 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -95087,8 +95087,7 @@ var LANGUAGE_TO_REGISTRY_TYPE = { rust: ["cargo_registry"], go: ["goproxy_server", "git_source"] }; -function getCredentials(logger, registrySecrets, registriesCredentials, languageString) { - const language = languageString ? parseLanguage(languageString) : void 0; +function getCredentials(logger, registrySecrets, registriesCredentials, language) { const registryTypeForLanguage = language ? LANGUAGE_TO_REGISTRY_TYPE[language] : void 0; let credentialsStr; if (registriesCredentials !== void 0) { @@ -95780,11 +95779,13 @@ async function runWrapper() { const tempDir = getTemporaryDirectory(); const proxyLogFilePath = path.resolve(tempDir, "proxy.log"); core11.saveState("proxy-log-file", proxyLogFilePath); + const languageInput = getOptionalInput("language"); + const language = languageInput ? parseLanguage(languageInput) : void 0; const credentials = getCredentials( logger, getOptionalInput("registry_secrets"), getOptionalInput("registries_credentials"), - getOptionalInput("language") + language ); if (credentials.length === 0) { logger.info("No credentials found, skipping proxy setup."); diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index 966c954b4..3de5e358b 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -12,6 +12,7 @@ import { Credential, getCredentials, getDownloadUrl, + parseLanguage, UPDATEJOB_PROXY, } from "./start-proxy"; import { @@ -133,11 +134,13 @@ async function runWrapper() { core.saveState("proxy-log-file", proxyLogFilePath); // Get the configuration options + const languageInput = actionsUtil.getOptionalInput("language"); + const language = languageInput ? parseLanguage(languageInput) : undefined; const credentials = getCredentials( logger, actionsUtil.getOptionalInput("registry_secrets"), actionsUtil.getOptionalInput("registries_credentials"), - actionsUtil.getOptionalInput("language"), + language, ); if (credentials.length === 0) { diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index dfd55d72f..edd1377c0 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -109,7 +109,7 @@ test("getCredentials filters by language when specified", async (t) => { getRunnerLogger(true), undefined, toEncodedJSON(mixedCredentials), - "java", + KnownLanguage.java, ); t.is(credentials.length, 1); t.is(credentials[0].type, "maven_repository"); @@ -120,7 +120,7 @@ test("getCredentials returns all for a language when specified", async (t) => { getRunnerLogger(true), undefined, toEncodedJSON(mixedCredentials), - "go", + KnownLanguage.go, ); t.is(credentials.length, 2); diff --git a/src/start-proxy.ts b/src/start-proxy.ts index dd1e443b7..2888e1a58 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -79,9 +79,8 @@ export function getCredentials( logger: Logger, registrySecrets: string | undefined, registriesCredentials: string | undefined, - languageString: string | undefined, + language: KnownLanguage | undefined, ): Credential[] { - const language = languageString ? parseLanguage(languageString) : undefined; const registryTypeForLanguage = language ? LANGUAGE_TO_REGISTRY_TYPE[language] : undefined;