Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): replace all uses of golang/protobuf/protobuf #3516

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.17
require (
github.com/antihax/optional v1.0.0
github.com/golang/glog v1.1.0
github.com/golang/protobuf v1.5.3
github.com/google/go-cmp v0.5.9
github.com/rogpeppe/fastuuid v1.2.0
golang.org/x/oauth2 v0.11.0
Expand All @@ -18,6 +17,7 @@ require (
)

require (
github.com/golang/protobuf v1.5.3 // indirect
johanbrandhorst marked this conversation as resolved.
Show resolved Hide resolved
github.com/kr/pretty v0.3.1 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions protoc-gen-openapiv2/internal/genopenapi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ go_library(
"//internal/descriptor",
"//internal/generator",
"//protoc-gen-openapiv2/options",
"@com_github_golang_protobuf//descriptor:go_default_library_gen",
"@com_github_golang_protobuf//ptypes/any",
"@in_gopkg_yaml_v3//:yaml_v3",
"@org_golang_google_genproto_googleapis_api//annotations",
"@org_golang_google_genproto_googleapis_api//visibility",
"@org_golang_google_genproto_googleapis_rpc//status",
"@org_golang_google_grpc//grpclog",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//proto",
"@org_golang_google_protobuf//reflect/protodesc",
"@org_golang_google_protobuf//types/descriptorpb",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/structpb",
"@org_golang_google_protobuf//types/pluginpb",
"@org_golang_x_text//cases",
Expand Down
19 changes: 6 additions & 13 deletions protoc-gen-openapiv2/internal/genopenapi/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ import (
"reflect"
"strings"

anypb "github.com/golang/protobuf/ptypes/any"
"github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor"
gen "github.com/grpc-ecosystem/grpc-gateway/v2/internal/generator"
openapi_options "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
openapioptions "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
statuspb "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc/grpclog"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/pluginpb"

//nolint:staticcheck // Known issue, will be replaced when possible
legacydescriptor "github.com/golang/protobuf/descriptor"
)

var errNoTargetService = errors.New("no target service defined in the file")
Expand Down Expand Up @@ -300,7 +298,7 @@ func (g *generator) Generate(targets []*descriptor.File) ([]*descriptor.Response
var mergedTarget *descriptor.File
// try to find proto leader
for _, f := range targets {
if proto.HasExtension(f.Options, openapi_options.E_Openapiv2Swagger) {
if proto.HasExtension(f.Options, openapioptions.E_Openapiv2Swagger) {
mergedTarget = f
break
}
Expand Down Expand Up @@ -370,13 +368,8 @@ func (g *generator) Generate(targets []*descriptor.File) ([]*descriptor.Response
// to registry (used for error-related API responses)
func AddErrorDefs(reg *descriptor.Registry) error {
// load internal protos
any, _ := legacydescriptor.MessageDescriptorProto(&anypb.Any{})
any.SourceCodeInfo = new(descriptorpb.SourceCodeInfo)
status, _ := legacydescriptor.MessageDescriptorProto(&statuspb.Status{})
status.SourceCodeInfo = new(descriptorpb.SourceCodeInfo)
// TODO(johanbrandhorst): Use new conversion later when possible
// any := protodesc.ToFileDescriptorProto((&anypb.Any{}).ProtoReflect().Descriptor().ParentFile())
// status := protodesc.ToFileDescriptorProto((&statuspb.Status{}).ProtoReflect().Descriptor().ParentFile())
any := protodesc.ToFileDescriptorProto((&anypb.Any{}).ProtoReflect().Descriptor().ParentFile())
status := protodesc.ToFileDescriptorProto((&statuspb.Status{}).ProtoReflect().Descriptor().ParentFile())
johanbrandhorst marked this conversation as resolved.
Show resolved Hide resolved
return reg.Load(&pluginpb.CodeGeneratorRequest{
ProtoFile: []*descriptorpb.FileDescriptorProto{
any,
Expand Down