Skip to content

Commit 02858ee

Browse files
Clement-Jeanarvindbr8dfawley
authored
deps: move from github.com/golang/protobuf to google.golang.org/protobuf/proto (#6919)
Co-authored-by: Arvind Bright <[email protected]> Co-authored-by: Doug Fawley <[email protected]>
1 parent 8d735f0 commit 02858ee

Some content is hidden

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

68 files changed

+165
-174
lines changed

balancer/grpclb/grpclb.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ import (
4444
"google.golang.org/grpc/internal/resolver/dns"
4545
"google.golang.org/grpc/resolver"
4646
"google.golang.org/grpc/resolver/manual"
47+
"google.golang.org/protobuf/types/known/durationpb"
4748

48-
durationpb "github.com/golang/protobuf/ptypes/duration"
4949
lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1"
5050
)
5151

balancer/grpclb/grpclb_remote_balancer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"sync"
2727
"time"
2828

29-
"github.com/golang/protobuf/proto"
3029
"google.golang.org/grpc"
3130
"google.golang.org/grpc/balancer"
3231
"google.golang.org/grpc/connectivity"
@@ -36,8 +35,9 @@ import (
3635
"google.golang.org/grpc/keepalive"
3736
"google.golang.org/grpc/metadata"
3837
"google.golang.org/grpc/resolver"
38+
"google.golang.org/protobuf/proto"
39+
"google.golang.org/protobuf/types/known/timestamppb"
3940

40-
timestamppb "github.com/golang/protobuf/ptypes/timestamp"
4141
lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1"
4242
)
4343

balancer/grpclb/grpclb_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ import (
5050
"google.golang.org/grpc/resolver/manual"
5151
"google.golang.org/grpc/serviceconfig"
5252
"google.golang.org/grpc/status"
53+
"google.golang.org/protobuf/types/known/durationpb"
5354

54-
durationpb "github.com/golang/protobuf/ptypes/duration"
5555
lbgrpc "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1"
5656
lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1"
5757
testgrpc "google.golang.org/grpc/interop/grpc_testing"

balancer/rls/config.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import (
2525
"net/url"
2626
"time"
2727

28-
"github.com/golang/protobuf/ptypes"
29-
durationpb "github.com/golang/protobuf/ptypes/duration"
3028
"google.golang.org/grpc/balancer"
3129
"google.golang.org/grpc/balancer/rls/internal/keys"
3230
"google.golang.org/grpc/internal"
@@ -35,6 +33,7 @@ import (
3533
"google.golang.org/grpc/resolver"
3634
"google.golang.org/grpc/serviceconfig"
3735
"google.golang.org/protobuf/encoding/protojson"
36+
"google.golang.org/protobuf/types/known/durationpb"
3837
)
3938

4039
const (
@@ -308,5 +307,5 @@ func convertDuration(d *durationpb.Duration) (time.Duration, error) {
308307
if d == nil {
309308
return 0, nil
310309
}
311-
return ptypes.Duration(d)
310+
return d.AsDuration(), d.CheckValid()
312311
}

binarylog/binarylog_end2end_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"testing"
2929
"time"
3030

31-
"github.com/golang/protobuf/proto"
3231
"google.golang.org/grpc"
3332
"google.golang.org/grpc/binarylog"
3433
"google.golang.org/grpc/codes"
@@ -39,6 +38,7 @@ import (
3938
"google.golang.org/grpc/internal/stubserver"
4039
"google.golang.org/grpc/metadata"
4140
"google.golang.org/grpc/status"
41+
"google.golang.org/protobuf/proto"
4242

4343
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
4444
testgrpc "google.golang.org/grpc/interop/grpc_testing"

credentials/alts/alts_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"testing"
2929
"time"
3030

31-
"github.com/golang/protobuf/proto"
3231
"google.golang.org/grpc"
3332
"google.golang.org/grpc/codes"
3433
"google.golang.org/grpc/credentials/alts/internal/handshaker"
@@ -42,6 +41,7 @@ import (
4241
testpb "google.golang.org/grpc/interop/grpc_testing"
4342
"google.golang.org/grpc/peer"
4443
"google.golang.org/grpc/status"
44+
"google.golang.org/protobuf/proto"
4545
)
4646

4747
const (

encoding/proto/proto.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ package proto
2323
import (
2424
"fmt"
2525

26-
"github.com/golang/protobuf/proto"
2726
"google.golang.org/grpc/encoding"
27+
"google.golang.org/protobuf/proto"
2828
)
2929

3030
// Name is the name registered for the proto compressor.

encoding/proto/proto_benchmark_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import (
2222
"fmt"
2323
"testing"
2424

25-
"github.com/golang/protobuf/proto"
2625
"google.golang.org/grpc/encoding"
26+
"google.golang.org/protobuf/proto"
27+
2728
pb "google.golang.org/grpc/test/codec_perf"
2829
)
2930

examples/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.19
44

55
require (
66
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa
7-
github.com/golang/protobuf v1.5.3
87
golang.org/x/oauth2 v0.16.0
98
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80
109
google.golang.org/grpc v1.60.1
@@ -19,6 +18,7 @@ require (
1918
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe // indirect
2019
github.com/envoyproxy/go-control-plane v0.12.0 // indirect
2120
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
21+
github.com/golang/protobuf v1.5.3 // indirect
2222
golang.org/x/net v0.20.0 // indirect
2323
golang.org/x/sync v0.6.0 // indirect
2424
golang.org/x/sys v0.16.0 // indirect

examples/route_guide/server/server.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ import (
3636
"time"
3737

3838
"google.golang.org/grpc"
39-
4039
"google.golang.org/grpc/credentials"
4140
"google.golang.org/grpc/examples/data"
42-
43-
"github.com/golang/protobuf/proto"
41+
"google.golang.org/protobuf/proto"
4442

4543
pb "google.golang.org/grpc/examples/route_guide/routeguide"
4644
)

internal/binarylog/method_logger.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ import (
2525
"sync/atomic"
2626
"time"
2727

28-
"github.com/golang/protobuf/proto"
29-
"github.com/golang/protobuf/ptypes"
3028
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
3129
"google.golang.org/grpc/metadata"
3230
"google.golang.org/grpc/status"
31+
"google.golang.org/protobuf/proto"
32+
"google.golang.org/protobuf/types/known/durationpb"
33+
"google.golang.org/protobuf/types/known/timestamppb"
3334
)
3435

3536
type callIDGenerator struct {
@@ -88,7 +89,7 @@ func NewTruncatingMethodLogger(h, m uint64) *TruncatingMethodLogger {
8889
// in TruncatingMethodLogger as possible.
8990
func (ml *TruncatingMethodLogger) Build(c LogEntryConfig) *binlogpb.GrpcLogEntry {
9091
m := c.toProto()
91-
timestamp, _ := ptypes.TimestampProto(time.Now())
92+
timestamp := timestamppb.Now()
9293
m.Timestamp = timestamp
9394
m.CallId = ml.callID
9495
m.SequenceIdWithinCall = ml.idWithinCallGen.next()
@@ -178,7 +179,7 @@ func (c *ClientHeader) toProto() *binlogpb.GrpcLogEntry {
178179
Authority: c.Authority,
179180
}
180181
if c.Timeout > 0 {
181-
clientHeader.Timeout = ptypes.DurationProto(c.Timeout)
182+
clientHeader.Timeout = durationpb.New(c.Timeout)
182183
}
183184
ret := &binlogpb.GrpcLogEntry{
184185
Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER,

internal/binarylog/method_logger_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import (
2626
"testing"
2727
"time"
2828

29-
"github.com/golang/protobuf/proto"
3029
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
3130
"google.golang.org/grpc/codes"
3231
"google.golang.org/grpc/status"
32+
"google.golang.org/protobuf/proto"
3333
"google.golang.org/protobuf/types/known/durationpb"
3434
)
3535

internal/binarylog/sink.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"sync"
2626
"time"
2727

28-
"github.com/golang/protobuf/proto"
2928
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
29+
"google.golang.org/protobuf/proto"
3030
)
3131

3232
var (

internal/pretty/pretty.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"encoding/json"
2525
"fmt"
2626

27-
"github.com/golang/protobuf/jsonpb"
2827
protov1 "github.com/golang/protobuf/proto"
2928
"google.golang.org/protobuf/encoding/protojson"
3029
protov2 "google.golang.org/protobuf/proto"
@@ -38,15 +37,15 @@ const jsonIndent = " "
3837
func ToJSON(e any) string {
3938
switch ee := e.(type) {
4039
case protov1.Message:
41-
mm := jsonpb.Marshaler{Indent: jsonIndent}
42-
ret, err := mm.MarshalToString(ee)
40+
mm := protojson.MarshalOptions{Indent: jsonIndent}
41+
ret, err := mm.Marshal(protov1.MessageV2(ee))
4342
if err != nil {
4443
// This may fail for proto.Anys, e.g. for xDS v2, LDS, the v2
4544
// messages are not imported, and this will fail because the message
4645
// is not found.
4746
return fmt.Sprintf("%+v", ee)
4847
}
49-
return ret
48+
return string(ret)
5049
case protov2.Message:
5150
mm := protojson.MarshalOptions{
5251
Multiline: true,

internal/status/status.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ import (
3131
"errors"
3232
"fmt"
3333

34-
"github.com/golang/protobuf/proto"
35-
"github.com/golang/protobuf/ptypes"
3634
spb "google.golang.org/genproto/googleapis/rpc/status"
3735
"google.golang.org/grpc/codes"
36+
"google.golang.org/protobuf/proto"
37+
"google.golang.org/protobuf/protoadapt"
38+
"google.golang.org/protobuf/types/known/anypb"
3839
)
3940

4041
// Status represents an RPC status code, message, and details. It is immutable
@@ -130,14 +131,14 @@ func (s *Status) Err() error {
130131

131132
// WithDetails returns a new status with the provided details messages appended to the status.
132133
// If any errors are encountered, it returns nil and the first error encountered.
133-
func (s *Status) WithDetails(details ...proto.Message) (*Status, error) {
134+
func (s *Status) WithDetails(details ...protoadapt.MessageV1) (*Status, error) {
134135
if s.Code() == codes.OK {
135136
return nil, errors.New("no error details for status with code OK")
136137
}
137138
// s.Code() != OK implies that s.Proto() != nil.
138139
p := s.Proto()
139140
for _, detail := range details {
140-
any, err := ptypes.MarshalAny(detail)
141+
any, err := anypb.New(protoadapt.MessageV2Of(detail))
141142
if err != nil {
142143
return nil, err
143144
}
@@ -154,12 +155,12 @@ func (s *Status) Details() []any {
154155
}
155156
details := make([]any, 0, len(s.s.Details))
156157
for _, any := range s.s.Details {
157-
detail := &ptypes.DynamicAny{}
158-
if err := ptypes.UnmarshalAny(any, detail); err != nil {
158+
detail, err := any.UnmarshalNew()
159+
if err != nil {
159160
details = append(details, err)
160161
continue
161162
}
162-
details = append(details, detail.Message)
163+
details = append(details, detail)
163164
}
164165
return details
165166
}

internal/testutils/marshal_any.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ package testutils
2020
import (
2121
"testing"
2222

23-
"github.com/golang/protobuf/proto"
24-
"google.golang.org/protobuf/protoadapt"
23+
"google.golang.org/protobuf/proto"
2524
"google.golang.org/protobuf/types/known/anypb"
2625
)
2726

@@ -30,7 +29,7 @@ import (
3029
func MarshalAny(t *testing.T, m proto.Message) *anypb.Any {
3130
t.Helper()
3231

33-
a, err := anypb.New(protoadapt.MessageV2Of(m))
32+
a, err := anypb.New(m)
3433
if err != nil {
3534
t.Fatalf("Failed to marshal proto %+v into an Any: %v", m, err)
3635
}

internal/testutils/status_equal.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
package testutils
2020

2121
import (
22-
"github.com/golang/protobuf/proto"
2322
"google.golang.org/grpc/status"
23+
"google.golang.org/protobuf/proto"
2424
)
2525

2626
// StatusErrEqual returns true iff both err1 and err2 wrap status.Status errors

internal/testutils/status_equal_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ package testutils
2121
import (
2222
"testing"
2323

24-
anypb "github.com/golang/protobuf/ptypes/any"
2524
spb "google.golang.org/genproto/googleapis/rpc/status"
2625
"google.golang.org/grpc/codes"
2726
"google.golang.org/grpc/internal/grpctest"
2827
"google.golang.org/grpc/status"
28+
"google.golang.org/protobuf/types/known/anypb"
2929
)
3030

3131
type s struct {

internal/testutils/xds/e2e/clientresources.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ import (
2323
"net"
2424
"strconv"
2525

26-
"google.golang.org/protobuf/protoadapt"
27-
2826
"github.com/envoyproxy/go-control-plane/pkg/wellknown"
29-
"github.com/golang/protobuf/proto"
27+
"google.golang.org/protobuf/proto"
3028
"google.golang.org/protobuf/types/known/anypb"
29+
"google.golang.org/protobuf/types/known/wrapperspb"
3130

3231
v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
3332
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
@@ -39,7 +38,6 @@ import (
3938
v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
4039
v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
4140
v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3"
42-
wrapperspb "github.com/golang/protobuf/ptypes/wrappers"
4341
)
4442

4543
const (
@@ -130,7 +128,7 @@ func DefaultClientListener(target, routeName string) *v3listenerpb.Listener {
130128
}
131129

132130
func marshalAny(m proto.Message) *anypb.Any {
133-
a, err := anypb.New(protoadapt.MessageV2Of(m))
131+
a, err := anypb.New(m)
134132
if err != nil {
135133
panic(fmt.Sprintf("anypb.New(%+v) failed: %v", m, err))
136134
}

internal/testutils/xds/fakeserver/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import (
2929
"net"
3030
"time"
3131

32-
"github.com/golang/protobuf/proto"
3332
"google.golang.org/grpc"
3433
"google.golang.org/grpc/codes"
3534
"google.golang.org/grpc/internal/testutils"
3635
"google.golang.org/grpc/status"
36+
"google.golang.org/protobuf/proto"
3737

3838
v3discoverygrpc "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
3939
v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"

internal/transport/handler_server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"sync"
3636
"time"
3737

38-
"github.com/golang/protobuf/proto"
3938
"golang.org/x/net/http2"
4039
"google.golang.org/grpc/codes"
4140
"google.golang.org/grpc/credentials"
@@ -45,6 +44,7 @@ import (
4544
"google.golang.org/grpc/peer"
4645
"google.golang.org/grpc/stats"
4746
"google.golang.org/grpc/status"
47+
"google.golang.org/protobuf/proto"
4848
)
4949

5050
// NewServerHandlerTransport returns a ServerTransport handling gRPC from

0 commit comments

Comments
 (0)