Use Language type
This commit is contained in:
parent
de0f9cf316
commit
31d11b19a0
6 changed files with 39 additions and 9 deletions
|
|
@ -6,6 +6,7 @@ import * as toolcache from "@actions/tool-cache";
|
|||
import { pki } from "node-forge";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { Language, parseLanguage } from "./languages";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import * as util from "./util";
|
||||
|
||||
|
|
@ -17,10 +18,18 @@ const PROXY_USER = "proxy_user";
|
|||
const KEY_SIZE = 2048;
|
||||
const KEY_EXPIRY_YEARS = 2;
|
||||
|
||||
const LANGUAGE_TO_REGISTRY_TYPE = {
|
||||
"java-kotlin": "maven_repository",
|
||||
const LANGUAGE_TO_REGISTRY_TYPE: Record<Language, string> = {
|
||||
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: "",
|
||||
} as const;
|
||||
|
||||
type CertificateAuthority = {
|
||||
|
|
@ -198,7 +207,11 @@ function getCredentials(logger: Logger): Credential[] {
|
|||
"registries_credentials",
|
||||
);
|
||||
const registrySecrets = actionsUtil.getOptionalInput("registry_secrets");
|
||||
const language = actionsUtil.getOptionalInput("language");
|
||||
const languageString = actionsUtil.getOptionalInput("language");
|
||||
const language = languageString ? parseLanguage(languageString) : undefined;
|
||||
const registryTypeForLanguage = language
|
||||
? LANGUAGE_TO_REGISTRY_TYPE[language]
|
||||
: undefined;
|
||||
|
||||
let credentialsStr: string;
|
||||
if (registriesCredentials !== undefined) {
|
||||
|
|
@ -222,7 +235,7 @@ function getCredentials(logger: Logger): Credential[] {
|
|||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue