Skip to content

Commit

Permalink
Filter registry credentials by language
Browse files Browse the repository at this point in the history
  • Loading branch information
marcogario committed Jan 13, 2025
1 parent e83e0a4 commit 4263e13
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/start-proxy-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/start-proxy-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/start-proxy-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const PROXY_USER = "proxy_user";
const KEY_SIZE = 2048;
const KEY_EXPIRY_YEARS = 2;

const LANGUAGE_TO_REGISTRY_TYPE: Record<string, string> = {
"java-kotlin": "maven_repository",
"csharp": "nuget_feed",

Check failure

Code scanning / ESLint

Ensure code is properly formatted, use insertion, deletion, or replacement to obtain desired formatting. Error

Replace "csharp" with csharp
};

type CertificateAuthority = {
cert: string;
key: string;
Expand Down Expand Up @@ -192,6 +197,7 @@ function getCredentials(logger: Logger): Credential[] {
"registries_credentials",
);
const registrySecrets = actionsUtil.getOptionalInput("registry_secrets");
const language = actionsUtil.getOptionalInput("language");

let credentialsStr: string;
if (registriesCredentials !== undefined) {
Expand All @@ -212,6 +218,13 @@ function getCredentials(logger: Logger): Credential[] {
if (e.url === undefined && e.host === undefined) {
throw new Error("Invalid credentials - must specify host or url");
}

// 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) {
continue;
}

out.push({
type: e.type,
host: e.host,
Expand Down
3 changes: 3 additions & 0 deletions start-proxy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
description: GitHub token to use for authenticating with this instance of GitHub, used to upload debug artifacts.
default: ${{ github.token }}
required: false
language:
description: The programming language to setup the proxy for the correct ecosystem
required: false
outputs:
proxy_host:
description: The IP address of the proxy
Expand Down

0 comments on commit 4263e13

Please sign in to comment.