Skip to content

Commit 8fe8b24

Browse files
committed
Add git_source as supported registry type for Go
1 parent 6242bcb commit 8fe8b24

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

lib/start-proxy-action.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy.test.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ setupTests(test);
1111
const toEncodedJSON = (data: any) =>
1212
Buffer.from(JSON.stringify(data)).toString("base64");
1313

14+
const mixedCredentials = [
15+
{ type: "npm_registry", host: "npm.pkg.github.com", token: "abc" },
16+
{ type: "maven_repository", host: "maven.pkg.github.com", token: "def" },
17+
{ type: "nuget_feed", host: "nuget.pkg.github.com", token: "ghi" },
18+
{ type: "goproxy_server", host: "goproxy.example.com", token: "jkl" },
19+
{ type: "git_source", host: "github.com/github", token: "mno" },
20+
];
21+
1422
test("getCredentials prefers registriesCredentials over registrySecrets", async (t) => {
1523
const registryCredentials = Buffer.from(
1624
JSON.stringify([
@@ -94,13 +102,6 @@ test("getCredentials throws error when credential missing host and url", async (
94102
});
95103

96104
test("getCredentials filters by language when specified", async (t) => {
97-
const mixedCredentials = [
98-
{ type: "npm_registry", host: "npm.pkg.github.com", token: "abc" },
99-
{ type: "maven_repository", host: "maven.pkg.github.com", token: "def" },
100-
{ type: "nuget_feed", host: "nuget.pkg.github.com", token: "ghi" },
101-
{ type: "goproxy_server", host: "goproxy.example.com", token: "jkl" },
102-
];
103-
104105
const credentials = startProxyExports.getCredentials(
105106
getRunnerLogger(true),
106107
undefined,
@@ -111,13 +112,21 @@ test("getCredentials filters by language when specified", async (t) => {
111112
t.is(credentials[0].type, "maven_repository");
112113
});
113114

115+
test("getCredentials returns all for a language when specified", async (t) => {
116+
const credentials = startProxyExports.getCredentials(
117+
getRunnerLogger(true),
118+
undefined,
119+
toEncodedJSON(mixedCredentials),
120+
"go",
121+
);
122+
t.is(credentials.length, 2);
123+
124+
const credentialsTypes = credentials.map((c) => c.type);
125+
t.assert(credentialsTypes.includes("goproxy_server"));
126+
t.assert(credentialsTypes.includes("git_source"));
127+
});
128+
114129
test("getCredentials returns all credentials when no language specified", async (t) => {
115-
const mixedCredentials = [
116-
{ type: "npm_registry", host: "npm.pkg.github.com", token: "abc" },
117-
{ type: "maven_repository", host: "maven.pkg.github.com", token: "def" },
118-
{ type: "nuget_feed", host: "nuget.pkg.github.com", token: "ghi" },
119-
{ type: "goproxy_server", host: "goproxy.example.com", token: "jkl" },
120-
];
121130
const credentialsInput = toEncodedJSON(mixedCredentials);
122131

123132
const credentials = startProxyExports.getCredentials(

src/start-proxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const LANGUAGE_TO_REGISTRY_TYPE: Partial<Record<KnownLanguage, string[]>> = {
6262
python: ["python_index"],
6363
ruby: ["rubygems_server"],
6464
rust: ["cargo_registry"],
65-
go: ["goproxy_server"],
65+
go: ["goproxy_server", "git_source"],
6666
} as const;
6767

6868
/**

0 commit comments

Comments
 (0)