Skip to content

Commit

Permalink
Merge branch 'main' into ed/listCommitsOnlyChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
emcfarlane committed Dec 27, 2024
2 parents bb5cddb + 088af34 commit bea51d0
Show file tree
Hide file tree
Showing 150 changed files with 84,551 additions and 4,328 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ linters:
- bidichk
- bodyclose
- containedctx
- copyloopvar
# - contextcheck
- decorder
# - depguard
- dogsled
- errcheck
- exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
- gci
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Fix `buf plugin push --label` to allow pushing a plugin with a label.
- Add `--only-changes` flag to `buf registry {module,plugin} commit list` to filter
out commits that have no digest changes.

Expand Down
2 changes: 1 addition & 1 deletion buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ modules:
name: buf.build/bufbuild/buf
lint:
use:
- DEFAULT
- STANDARD
- UNARY_RPC
disallow_comment_ignores: true
breaking:
Expand Down
3 changes: 2 additions & 1 deletion data/template/buf.go.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ plugins:
out: private/gen/proto/go
opt:
- paths=source_relative
- default_api_level=API_HYBRID
- Mgoogle/protobuf/cpp_features.proto=github.com/bufbuild/buf/private/gen/proto/go/google/protobuf
- Mgoogle/protobuf/java_features.proto=github.com/bufbuild/buf/private/gen/proto/go/google/protobuf
inputs:
- directory: proto
- module: buf.build/grpc/grpc
types:
- grpc.reflection.v1.ServerReflection
- module: buf.build/protocolbuffers/wellknowntypes:v27.0
- module: buf.build/protocolbuffers/wellknowntypes:v29.1
paths:
- google/protobuf/cpp_features.proto
- google/protobuf/java_features.proto
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ go 1.22.0
toolchain go1.23.4

require (
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.0-20241031151143-70f632351282.1
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.0-20241127180247-a33202765966.1
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.1-20241031151143-70f632351282.1
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.1-20241127180247-a33202765966.1
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241210175624-28487aef65cd.1
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.0-20241210175624-28487aef65cd.1
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.1-20241210175624-28487aef65cd.1
buf.build/go/bufplugin v0.6.0
buf.build/go/protoyaml v0.3.1
buf.build/go/spdx v0.2.0
Expand Down Expand Up @@ -47,13 +47,13 @@ require (
golang.org/x/sync v0.10.0
golang.org/x/term v0.27.0
golang.org/x/tools v0.28.0
google.golang.org/protobuf v1.36.0
google.golang.org/protobuf v1.36.1
gopkg.in/yaml.v3 v3.0.1
pluginrpc.com/pluginrpc v0.5.0
)

require (
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.0-20241007202033-cf42259fcbfc.1 // indirect
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.1-20241007202033-cf42259fcbfc.1 // indirect
cel.dev/expr v0.19.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
Expand Down Expand Up @@ -98,7 +98,7 @@ require (
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/onsi/ginkgo/v2 v2.22.0 // indirect
github.com/onsi/ginkgo/v2 v2.22.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
Expand All @@ -123,7 +123,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241219192143-6b3ec007d9bb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219192143-6b3ec007d9bb // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241223144023-3abc09e42ca8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
google.golang.org/grpc v1.69.2 // indirect
)
36 changes: 18 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.0-20241031151143-70f632351282.1 h1:FXEFgDFrBYuXjn3twNRo/t80qSbdKmkfZSgR2JGTuyk=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.0-20241031151143-70f632351282.1/go.mod h1:/bPD5uslGsdRKBeVavIK7D7yr+3ISI0OoyUOkokSJTA=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.0-20241127180247-a33202765966.1 h1:ntAj16eF7AtUyzOOAFk5gvbAO52QmUKPKk7GmsIEORo=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.0-20241127180247-a33202765966.1/go.mod h1:AxRT+qTj5PJCz2nyQzsR/qxAcveW5USRhJTt/edTO5w=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.1-20241031151143-70f632351282.1 h1:DELauram5j4snPU5wB0/I7EIQiy7oRjngqbitbj4o6c=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.1-20241031151143-70f632351282.1/go.mod h1:VfQZo/3dl9O9Yg1nseI0gNGDXvLrNQfBRMMIhV9fyII=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.1-20241127180247-a33202765966.1 h1:v223wh/bhlSHSc0tU9PXRWXHhkw3UWMtth7TmYGfHAQ=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.1-20241127180247-a33202765966.1/go.mod h1:/zlFuuECgFgewxwW6qQKgvMJ07YZkWlVkcSxEhJprJw=
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241210175624-28487aef65cd.1 h1:x8cCitPNXODGzWbfApZMFc4ALtRe5LZJmTdAkNqk62A=
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241210175624-28487aef65cd.1/go.mod h1:kDOQd1sZ0wRp33hvCTQeaz9KprnHNfJ+a8dcIQ/6+0k=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.0-20241210175624-28487aef65cd.1 h1:NOuNS+nCp3xc4CALIC7sNz7irT63UMcYAfofrxurUfE=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.0-20241210175624-28487aef65cd.1/go.mod h1:NeX3YCZgM9E/wNp9e3g/9u5bu8/OPntr7K0ygUlgrDE=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.0-20241007202033-cf42259fcbfc.1 h1:HuK77NuzllXrJNgB+lAtnG2dKrB7WAjd9QQ+n0zTQHc=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.0-20241007202033-cf42259fcbfc.1/go.mod h1:BLQCnWbu3tZcKQfbU1f5ysbRk55FDFwOvjlyzN+uLXg=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.1-20241210175624-28487aef65cd.1 h1:VU8k1n06qmuNXtI/LekXyjxAtG0NQdZtbmLSkBUjIm4=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.1-20241210175624-28487aef65cd.1/go.mod h1:DgqZjUk2avpwh8jiMHBOoVXUyceQ3HxNwcRLEWWwNtQ=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.1-20241007202033-cf42259fcbfc.1 h1:0Pi0EQh6z2zJigi4UonoqczBQjvOzZ0CFYUfwPRM41M=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.1-20241007202033-cf42259fcbfc.1/go.mod h1:Uy8SKofLXIAUjswDmz6AIN8W+bGVTF4kNczZikMPHLM=
buf.build/go/bufplugin v0.6.0 h1:3lhoh+0z+IUPS3ZajTPn/27LaLIkero2BDVnV7yXD1s=
buf.build/go/bufplugin v0.6.0/go.mod h1:hWCjxxv24xdR6F5pNlQavZV2oo0J3uF4Ff1XEoyV6vU=
buf.build/go/protoyaml v0.3.1 h1:ucyzE7DRnjX+mQ6AH4JzN0Kg50ByHHu+yrSKbgQn2D4=
Expand Down Expand Up @@ -203,10 +203,10 @@ github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8=
github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc=
github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM=
github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM=
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
Expand Down Expand Up @@ -377,10 +377,10 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto/googleapis/api v0.0.0-20241219192143-6b3ec007d9bb h1:B7GIB7sr443wZ/EAEl7VZjmh1V6qzkt5V+RYcUYtS1U=
google.golang.org/genproto/googleapis/api v0.0.0-20241219192143-6b3ec007d9bb/go.mod h1:E5//3O5ZIG2l71Xnt+P/CYUY8Bxs8E7WMoZ9tlcMbAY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219192143-6b3ec007d9bb h1:3oy2tynMOP1QbTC0MsNNAV+Se8M2Bd0A5+x1QHyw+pI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219192143-6b3ec007d9bb/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
google.golang.org/genproto/googleapis/api v0.0.0-20241223144023-3abc09e42ca8 h1:st3LcW/BPi75W4q1jJTEor/QWwbNlPlDG0JTn6XhZu0=
google.golang.org/genproto/googleapis/api v0.0.0-20241223144023-3abc09e42ca8/go.mod h1:klhJGKFyG8Tn50enBn7gizg4nXGXJ+jqEREdCWaPcV4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 h1:TqExAhdPaB60Ux47Cn0oLV07rGnxZzIsaRhQaqS666A=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
Expand All @@ -397,8 +397,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=
google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
2 changes: 1 addition & 1 deletion make/buf/all.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ LICENSE_HEADER_YEAR_RANGE := 2020-2024
LICENSE_HEADER_IGNORES := \/testdata enterprise
PROTOVALIDATE_VERSION := v0.8.1
# Comment out to use released buf
BUF_GO_INSTALL_PATH := ./cmd/buf
#BUF_GO_INSTALL_PATH := ./cmd/buf

BUF_LINT_INPUT := .
BUF_BREAKING_INPUT := .
Expand Down
4 changes: 2 additions & 2 deletions make/go/dep_buf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ $(call _assert_var,CACHE_VERSIONS)
$(call _assert_var,CACHE_BIN)

# Settable
# https://github.com/bufbuild/buf/releases 20241114 checked 20241114
BUF_VERSION ?= v1.47.2
# https://github.com/bufbuild/buf/releases 20241219 checked 20241219
BUF_VERSION ?= v1.48.0
# Settable
#
# If set, this path will be installed every time someone depends on $(BUF)
Expand Down
4 changes: 2 additions & 2 deletions make/go/dep_protoc_gen_go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ $(call _assert_var,CACHE_VERSIONS)
$(call _assert_var,CACHE_BIN)

# Settable
# https://github.com/protocolbuffers/protobuf-go/releases 20241216 checked 20241217
PROTOC_GEN_GO_VERSION ?= v1.36.0
# https://github.com/protocolbuffers/protobuf-go/releases 20241223 checked 20241227
PROTOC_GEN_GO_VERSION ?= v1.36.1

GO_GET_PKGS := $(GO_GET_PKGS) \
google.golang.org/protobuf/proto@$(PROTOC_GEN_GO_VERSION)
Expand Down
6 changes: 3 additions & 3 deletions private/buf/bufctl/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,8 @@ func (c *controller) getImageForMessageRef(
}

if functionOptions.imageExcludeSourceInfo {
for _, fileDescriptorProto := range protoImage.File {
fileDescriptorProto.SourceCodeInfo = nil
for _, fileDescriptorProto := range protoImage.GetFile() {
fileDescriptorProto.ClearSourceCodeInfo()
}
}

Expand Down Expand Up @@ -1315,7 +1315,7 @@ func bootstrapResolver(
if err := unmarshaler.Unmarshal(data, firstProtoImage); err != nil {
return nil, err
}
return protoencoding.NewResolver(firstProtoImage.File...)
return protoencoding.NewResolver(firstProtoImage.GetFile()...)
}

// WE DO NOT FILTER IF WE ALREADY FILTERED ON BUILDING OF A WORKSPACE
Expand Down
77 changes: 35 additions & 42 deletions private/buf/bufcurl/reflection_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
reflectionv1 "github.com/bufbuild/buf/private/gen/proto/go/grpc/reflection/v1"
"github.com/bufbuild/buf/private/pkg/protoencoding"
"github.com/bufbuild/buf/private/pkg/verbose"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
Expand Down Expand Up @@ -154,30 +155,28 @@ func (r *reflectionResolver) ListServices() ([]protoreflect.FullName, error) {
defer r.mu.Unlock()

r.printer.Printf("* Using server reflection to list services\n")
resp, err := r.sendLocked(&reflectionv1.ServerReflectionRequest{
MessageRequest: &reflectionv1.ServerReflectionRequest_ListServices{
ListServices: "",
},
})
resp, err := r.sendLocked(reflectionv1.ServerReflectionRequest_builder{
ListServices: proto.String(""),
}.Build())
if err != nil {
return nil, err
}
switch response := resp.MessageResponse.(type) {
case *reflectionv1.ServerReflectionResponse_ErrorResponse:
switch resp.WhichMessageResponse() {
case reflectionv1.ServerReflectionResponse_ErrorResponse_case:
// This should never happen, however we do a bounds check to ensure we are doing a safe
// conversion from int32 (ErrorResponse.ErrorCode) to uint32 (connect.Code).
if response.ErrorResponse.ErrorCode < 0 {
return nil, fmt.Errorf("server replied with unsupported error code: %v", response.ErrorResponse.ErrorCode)
if resp.GetErrorResponse().GetErrorCode() < 0 {
return nil, fmt.Errorf("server replied with unsupported error code: %v", resp.GetErrorResponse().GetErrorCode())
}
return nil, connect.NewWireError(connect.Code(response.ErrorResponse.ErrorCode), errors.New(response.ErrorResponse.ErrorMessage))
case *reflectionv1.ServerReflectionResponse_ListServicesResponse:
serviceNames := make([]protoreflect.FullName, len(response.ListServicesResponse.Service))
for i, service := range response.ListServicesResponse.Service {
serviceNames[i] = protoreflect.FullName(service.Name)
return nil, connect.NewWireError(connect.Code(resp.GetErrorResponse().GetErrorCode()), errors.New(resp.GetErrorResponse().GetErrorMessage()))
case reflectionv1.ServerReflectionResponse_ListServicesResponse_case:
serviceNames := make([]protoreflect.FullName, len(resp.GetListServicesResponse().GetService()))
for i, service := range resp.GetListServicesResponse().GetService() {
serviceNames[i] = protoreflect.FullName(service.GetName())
}
return serviceNames, nil
default:
return nil, fmt.Errorf("server replied with unsupported response type: %T", resp.MessageResponse)
return nil, fmt.Errorf("server replied with unsupported response type: %v", resp.WhichMessageResponse())
}
}

Expand Down Expand Up @@ -300,11 +299,9 @@ func (r *reflectionResolver) FindExtensionByNumber(message protoreflect.FullName

func (r *reflectionResolver) fileContainingSymbolLocked(name protoreflect.FullName) ([]*descriptorpb.FileDescriptorProto, error) {
r.printer.Printf("* Using server reflection to resolve %q\n", name)
resp, err := r.sendLocked(&reflectionv1.ServerReflectionRequest{
MessageRequest: &reflectionv1.ServerReflectionRequest_FileContainingSymbol{
FileContainingSymbol: string(name),
},
})
resp, err := r.sendLocked(reflectionv1.ServerReflectionRequest_builder{
FileContainingSymbol: proto.String(string(name)),
}.Build())
if err != nil {
return nil, err
}
Expand All @@ -313,14 +310,12 @@ func (r *reflectionResolver) fileContainingSymbolLocked(name protoreflect.FullNa

func (r *reflectionResolver) fileContainingExtensionLocked(message protoreflect.FullName, field protoreflect.FieldNumber) ([]*descriptorpb.FileDescriptorProto, error) {
r.printer.Printf("* Using server reflection to retrieve extension %d for %q\n", field, message)
resp, err := r.sendLocked(&reflectionv1.ServerReflectionRequest{
MessageRequest: &reflectionv1.ServerReflectionRequest_FileContainingExtension{
FileContainingExtension: &reflectionv1.ExtensionRequest{
ContainingType: string(message),
ExtensionNumber: int32(field),
},
},
})
resp, err := r.sendLocked(reflectionv1.ServerReflectionRequest_builder{
FileContainingExtension: reflectionv1.ExtensionRequest_builder{
ContainingType: string(message),
ExtensionNumber: int32(field),
}.Build(),
}.Build())
if err != nil {
return nil, err
}
Expand All @@ -329,29 +324,27 @@ func (r *reflectionResolver) fileContainingExtensionLocked(message protoreflect.

func (r *reflectionResolver) fileByNameLocked(name string) ([]*descriptorpb.FileDescriptorProto, error) {
r.printer.Printf("* Using server reflection to download file %q\n", name)
resp, err := r.sendLocked(&reflectionv1.ServerReflectionRequest{
MessageRequest: &reflectionv1.ServerReflectionRequest_FileByFilename{
FileByFilename: name,
},
})
resp, err := r.sendLocked(reflectionv1.ServerReflectionRequest_builder{
FileByFilename: proto.String(name),
}.Build())
if err != nil {
return nil, err
}
return descriptorsInResponse(resp)
}

func descriptorsInResponse(resp *reflectionv1.ServerReflectionResponse) ([]*descriptorpb.FileDescriptorProto, error) {
switch response := resp.MessageResponse.(type) {
case *reflectionv1.ServerReflectionResponse_ErrorResponse:
switch resp.WhichMessageResponse() {
case reflectionv1.ServerReflectionResponse_ErrorResponse_case:
// This should never happen, however we do a bounds check to ensure we are doing a safe
// conversion from int32 (ErrorResponse.ErrorCode) to uint32 (connect.Code).
if response.ErrorResponse.ErrorCode < 0 {
return nil, fmt.Errorf("server replied with unsupported error code: %v", response.ErrorResponse.ErrorCode)
if resp.GetErrorResponse().GetErrorCode() < 0 {
return nil, fmt.Errorf("server replied with unsupported error code: %v", resp.GetErrorResponse().GetErrorCode())
}
return nil, connect.NewWireError(connect.Code(response.ErrorResponse.ErrorCode), errors.New(response.ErrorResponse.ErrorMessage))
case *reflectionv1.ServerReflectionResponse_FileDescriptorResponse:
files := make([]*descriptorpb.FileDescriptorProto, len(response.FileDescriptorResponse.FileDescriptorProto))
for i, data := range response.FileDescriptorResponse.FileDescriptorProto {
return nil, connect.NewWireError(connect.Code(resp.GetErrorResponse().GetErrorCode()), errors.New(resp.GetErrorResponse().GetErrorMessage()))
case reflectionv1.ServerReflectionResponse_FileDescriptorResponse_case:
files := make([]*descriptorpb.FileDescriptorProto, len(resp.GetFileDescriptorResponse().GetFileDescriptorProto()))
for i, data := range resp.GetFileDescriptorResponse().GetFileDescriptorProto() {
var file descriptorpb.FileDescriptorProto
if err := protoencoding.NewWireUnmarshaler(nil).Unmarshal(data, &file); err != nil {
return nil, err
Expand All @@ -360,7 +353,7 @@ func descriptorsInResponse(resp *reflectionv1.ServerReflectionResponse) ([]*desc
}
return files, nil
default:
return nil, fmt.Errorf("server replied with unsupported response type: %T", resp.MessageResponse)
return nil, fmt.Errorf("server replied with unsupported response type: %v", resp.WhichMessageResponse())
}
}

Expand Down
1 change: 0 additions & 1 deletion private/buf/bufformat/bufformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func FormatBucket(ctx context.Context, bucket storage.ReadBucket) (_ storage.Rea
}
jobs := make([]func(context.Context) error, len(paths))
for i, path := range paths {
path := path
jobs[i] = func(ctx context.Context) (retErr error) {
readObjectCloser, err := bucket.Get(ctx, path)
if err != nil {
Expand Down
Loading

0 comments on commit bea51d0

Please sign in to comment.