Skip to content

Commit a57c6cd

Browse files
committed
Add EmitPrivateRegistryUsed
1 parent 8b03608 commit a57c6cd

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

go/extractor/diagnostics/diagnostics.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,3 +568,24 @@ func EmitExtractionFailedForProjects(path []string) {
568568
noLocation,
569569
)
570570
}
571+
572+
func EmitPrivateRegistryUsed(writer DiagnosticsWriter, configs []string) {
573+
lines := []string{}
574+
575+
for i := range configs {
576+
lines = append(lines, fmt.Sprintf("* %s", configs[i]))
577+
}
578+
579+
emitDiagnosticTo(
580+
writer,
581+
"go/autobuilder/analysis-using-private-registries",
582+
"Go extraction used private package registries",
583+
fmt.Sprintf(
584+
"Go was extracted using the following private package registrie%s:\n\n%s\n",
585+
plural(len(lines), "", "s"),
586+
strings.Join(lines, "\n")),
587+
severityNote,
588+
fullVisibility,
589+
noLocation,
590+
)
591+
}

go/extractor/diagnostics/diagnostics_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,24 @@ func Test_EmitCannotFindPackages_Actions(t *testing.T) {
8383
// Custom build command suggestion
8484
assert.Contains(t, d.MarkdownMessage, "If any of the packages are already present in the repository")
8585
}
86+
87+
func Test_EmitPrivateRegistryUsed(t *testing.T) {
88+
writer := newMemoryDiagnosticsWriter()
89+
90+
testItems := []string{
91+
"* https://github.com/github/example (Git Source)",
92+
"* https://example.com/goproxy (GOPROXY Server)",
93+
}
94+
95+
EmitPrivateRegistryUsed(writer, testItems)
96+
97+
assert.Len(t, writer.diagnostics, 1, "Expected one diagnostic to be emitted")
98+
99+
d := writer.diagnostics[0]
100+
assert.Equal(t, d.Source.Id, "go/autobuilder/analysis-using-private-registries")
101+
assert.Equal(t, d.Severity, string(severityNote))
102+
103+
for i := range testItems {
104+
assert.Contains(t, d.MarkdownMessage, testItems[i])
105+
}
106+
}

0 commit comments

Comments
 (0)