Use Language type

This commit is contained in:
Marco Gario
2025-01-14 14:20:23 +00:00
parent de0f9cf316
commit 31d11b19a0
6 changed files with 39 additions and 9 deletions

View File

@@ -39,6 +39,7 @@ const core = __importStar(require("@actions/core"));
const toolcache = __importStar(require("@actions/tool-cache"));
const node_forge_1 = require("node-forge");
const actionsUtil = __importStar(require("./actions-util"));
const languages_1 = require("./languages");
const logging_1 = require("./logging");
const util = __importStar(require("./util"));
const UPDATEJOB_PROXY = "update-job-proxy";
@@ -48,9 +49,17 @@ const PROXY_USER = "proxy_user";
const KEY_SIZE = 2048;
const KEY_EXPIRY_YEARS = 2;
const LANGUAGE_TO_REGISTRY_TYPE = {
"java-kotlin": "maven_repository",
java: "maven_repository",
csharp: "nuget_feed",
javascript: "npm_registry",
python: "python_index",
ruby: "rubygems_server",
rust: "cargo_registry",
// We do not have an established proxy type for these languages, thus leaving empty.
actions: "",
cpp: "",
go: "",
swift: "",
};
const CERT_SUBJECT = [
{
@@ -175,7 +184,11 @@ async function startProxy(binPath, config, logFilePath, logger) {
function getCredentials(logger) {
const registriesCredentials = actionsUtil.getOptionalInput("registries_credentials");
const registrySecrets = actionsUtil.getOptionalInput("registry_secrets");
const language = actionsUtil.getOptionalInput("language");
const languageString = actionsUtil.getOptionalInput("language");
const language = languageString ? (0, languages_1.parseLanguage)(languageString) : undefined;
const registryTypeForLanguage = language
? LANGUAGE_TO_REGISTRY_TYPE[language]
: undefined;
let credentialsStr;
if (registriesCredentials !== undefined) {
logger.info(`Using registries_credentials input.`);
@@ -198,7 +211,7 @@ function getCredentials(logger) {
}
// Filter credentials based on language if specified. `type` is the registry type.
// E.g., "maven_feed" for Java/Kotlin, "nuget_repository" for C#.
if (language && LANGUAGE_TO_REGISTRY_TYPE[language] !== e.type) {
if (e.type !== registryTypeForLanguage) {
continue;
}
out.push({