Skip to content

Commit f33e08c

Browse files
committed
Use Language type
1 parent de0f9cf commit f33e08c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/languages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export const LANGUAGE_ALIASES: { [lang: string]: Language } = {
1919
"c#": Language.csharp,
2020
kotlin: Language.java,
2121
typescript: Language.javascript,
22+
"javascript-typescript": Language.javascript,
23+
"java-kotlin": Language.java,
2224
};
2325

2426
/**

src/start-proxy-action.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { pki } from "node-forge";
88
import * as actionsUtil from "./actions-util";
99
import { getActionsLogger, Logger } from "./logging";
1010
import * as util from "./util";
11+
import { Language, parseLanguage } from "./languages";
1112

1213
const UPDATEJOB_PROXY = "update-job-proxy";
1314
const UPDATEJOB_PROXY_VERSION = "v2.0.20241023203727";
@@ -17,10 +18,18 @@ const PROXY_USER = "proxy_user";
1718
const KEY_SIZE = 2048;
1819
const KEY_EXPIRY_YEARS = 2;
1920

20-
const LANGUAGE_TO_REGISTRY_TYPE = {
21-
"java-kotlin": "maven_repository",
21+
const LANGUAGE_TO_REGISTRY_TYPE: Record<Language, string> = {
2222
java: "maven_repository",
2323
csharp: "nuget_feed",
24+
javascript: "npm_registry",
25+
python: "python_index",
26+
ruby: "rubygems_server",
27+
rust: "cargo_registry",
28+
// We do not have an established proxy type for these languages, thus leaving empty.
29+
actions: "",
30+
cpp: "",
31+
go: "",
32+
swift: "",
2433
} as const;
2534

2635
type CertificateAuthority = {
@@ -198,7 +207,9 @@ function getCredentials(logger: Logger): Credential[] {
198207
"registries_credentials",
199208
);
200209
const registrySecrets = actionsUtil.getOptionalInput("registry_secrets");
201-
const language = actionsUtil.getOptionalInput("language");
210+
const languageString = actionsUtil.getOptionalInput("language");
211+
const language = languageString ? parseLanguage(languageString) : undefined;
212+
const registryTypeForLanguage = language ? LANGUAGE_TO_REGISTRY_TYPE[language] : undefined;
202213

203214
let credentialsStr: string;
204215
if (registriesCredentials !== undefined) {
@@ -222,8 +233,8 @@ function getCredentials(logger: Logger): Credential[] {
222233

223234
// Filter credentials based on language if specified. `type` is the registry type.
224235
// E.g., "maven_feed" for Java/Kotlin, "nuget_repository" for C#.
225-
if (language && LANGUAGE_TO_REGISTRY_TYPE[language] !== e.type) {
226-
continue;
236+
if (e.type != registryTypeForLanguage) {
237+
continue;
227238
}
228239

229240
out.push({

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy