Skip to content

Commit eac0318

Browse files
authored
Use the new compiler for building images (#4407)
1 parent 40154e3 commit eac0318

43 files changed

Lines changed: 1122 additions & 1130 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ linters:
253253
- linters:
254254
- containedctx
255255
# we actually want to embed a context here
256-
path: private/bufpkg/bufimage/parser_accessor_handler.go
256+
path: private/bufpkg/bufimage/module_file_resolver.go
257257
- linters:
258258
- containedctx
259259
# we actually want to embed a context here
@@ -449,6 +449,13 @@ linters:
449449
# term.IsTerminal. Safe on all supported platforms.
450450
path: private/pkg/slogapp/console.go
451451
text: "G115:"
452+
- linters:
453+
- gosec
454+
# G115: uintptr->int conversion for passing a terminal file descriptor
455+
# to term.IsTerminal, which requires int. Safe on all supported platforms;
456+
# fd values fit in int.
457+
path: private/buf/bufctl/controller.go
458+
text: "G115:"
452459
- linters:
453460
- gosec
454461
# G602: false positive — the loop index i is bounded by the length of

cmd/buf/buf_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4493,7 +4493,10 @@ func TestProtoFileNoWorkspaceOrModule(t *testing.T) {
44934493
nil,
44944494
bufctl.ExitCodeFileAnnotation,
44954495
"", // no stdout
4496-
filepath.FromSlash(`testdata/protofileref/noworkspaceormodule/fail/import.proto:3:8:import "`)+`google/type/date.proto": file does not exist`,
4496+
fmt.Sprintf(
4497+
"%[1]s:3:1:imported file does not exist\n%[1]s:6:3:cannot find `google.type.Date` in this scope",
4498+
filepath.FromSlash("testdata/protofileref/noworkspaceormodule/fail/import.proto"),
4499+
),
44974500
"build",
44984501
filepath.Join("testdata", "protofileref", "noworkspaceormodule", "fail", "import.proto"),
44994502
)

cmd/buf/imports_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package main
1616

1717
import (
18+
"fmt"
1819
"io"
1920
"path/filepath"
2021
"strings"
@@ -148,7 +149,10 @@ func TestInvalidNonexistentImport(t *testing.T) {
148149
t.Parallel()
149150
testRunStderrWithCache(
150151
t, nil, bufctl.ExitCodeFileAnnotation,
151-
filepath.FromSlash(`testdata/imports/failure/people/people/v1/people1.proto:5:8:import "nonexistent.proto": file does not exist`),
152+
fmt.Sprintf(
153+
"%[1]s:5:1:imported file does not exist",
154+
filepath.FromSlash("testdata/imports/failure/people/people/v1/people1.proto"),
155+
),
152156
"build",
153157
filepath.Join("testdata", "imports", "failure", "people"),
154158
)
@@ -158,7 +162,10 @@ func TestInvalidNonexistentImportFromDirectDep(t *testing.T) {
158162
t.Parallel()
159163
testRunStderrWithCache(
160164
t, nil, bufctl.ExitCodeFileAnnotation,
161-
filepath.FromSlash(`testdata/imports/failure/students/students/v1/students.proto:`)+`6:8:import "people/v1/people_nonexistent.proto": file does not exist`,
165+
fmt.Sprintf(
166+
"%[1]s:6:1:imported file does not exist\n%[1]s:10:3:cannot find `people.v1.Person2` in this scope",
167+
filepath.FromSlash("testdata/imports/failure/students/students/v1/students.proto"),
168+
),
162169
"build",
163170
filepath.Join("testdata", "imports", "failure", "students"),
164171
)

cmd/buf/internal/command/breaking/breaking.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func run(
181181
container,
182182
bufctl.WithDisableSymlinks(flags.DisableSymlinks),
183183
bufctl.WithFileAnnotationErrorFormat(flags.ErrorFormat),
184+
bufctl.WithColorizedFileAnnotationSetDiagnosticReport(container.LogFormat() == appext.LogFormatColor),
184185
bufctl.WithFileAnnotationsToStdout(),
185186
)
186187
if err != nil {
@@ -368,7 +369,7 @@ func run(
368369
}
369370
}
370371
if len(allFileAnnotations) > 0 {
371-
allFileAnnotationSet := bufanalysis.NewFileAnnotationSet(allFileAnnotations...)
372+
allFileAnnotationSet := bufanalysis.NewFileAnnotationSet(nil, allFileAnnotations...)
372373
if err := bufanalysis.PrintFileAnnotationSet(
373374
container.Stdout(),
374375
allFileAnnotationSet,

cmd/buf/internal/command/build/build.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func run(
152152
container,
153153
bufctl.WithDisableSymlinks(flags.DisableSymlinks),
154154
bufctl.WithFileAnnotationErrorFormat(flags.ErrorFormat),
155+
bufctl.WithColorizedFileAnnotationSetDiagnosticReport(container.LogFormat() == appext.LogFormatColor),
155156
)
156157
if err != nil {
157158
return err

cmd/buf/internal/command/convert/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func run(
174174
container,
175175
bufctl.WithDisableSymlinks(flags.DisableSymlinks),
176176
bufctl.WithFileAnnotationErrorFormat(flags.ErrorFormat),
177+
bufctl.WithColorizedFileAnnotationSetDiagnosticReport(container.LogFormat() == appext.LogFormatColor),
177178
)
178179
if err != nil {
179180
return err

cmd/buf/internal/command/curl/curl.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,12 @@ func completeURLFromSchema(ctx context.Context, schemas []string, baseURL, rawPa
13341334
return nil, cobra.ShellCompDirectiveNoFileComp
13351335
}
13361336
// Discard log output during shell completion.
1337-
container := appext.NewContainer(nameContainer, slog.New(slog.NewTextHandler(io.Discard, nil)))
1337+
container := appext.NewContainer(
1338+
nameContainer,
1339+
slog.New(slog.NewTextHandler(io.Discard, nil)),
1340+
appext.LogLevelError, // Doesn't matter, logs are discarded
1341+
appext.LogFormatText, // Doesn't matter, logs are discarded
1342+
)
13381343
controller, err := bufcli.NewController(container)
13391344
if err != nil {
13401345
reportError("%v", err)

cmd/buf/internal/command/dep/depgraph/depgraph.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ func run(
155155
container,
156156
bufctl.WithDisableSymlinks(flags.DisableSymlinks),
157157
bufctl.WithFileAnnotationErrorFormat(flags.ErrorFormat),
158+
bufctl.WithColorizedFileAnnotationSetDiagnosticReport(container.LogFormat() == appext.LogFormatColor),
158159
)
159160
if err != nil {
160161
return err

cmd/buf/internal/command/format/format.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ func run(
296296
container,
297297
bufctl.WithDisableSymlinks(flags.DisableSymlinks),
298298
bufctl.WithFileAnnotationErrorFormat(flags.ErrorFormat),
299+
bufctl.WithColorizedFileAnnotationSetDiagnosticReport(container.LogFormat() == appext.LogFormatColor),
299300
)
300301
if err != nil {
301302
return err

cmd/buf/internal/command/generate/generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ func run(
534534
container,
535535
bufctl.WithDisableSymlinks(flags.DisableSymlinks),
536536
bufctl.WithFileAnnotationErrorFormat(flags.ErrorFormat),
537+
bufctl.WithColorizedFileAnnotationSetDiagnosticReport(container.LogFormat() == appext.LogFormatColor),
537538
)
538539
if err != nil {
539540
return err

0 commit comments

Comments
 (0)