diff --git a/balancer/grpclb/grpclb.go b/balancer/grpclb/grpclb.go index 86ba65be4c00..47a3e938dcf5 100644 --- a/balancer/grpclb/grpclb.go +++ b/balancer/grpclb/grpclb.go @@ -44,8 +44,8 @@ import ( "google.golang.org/grpc/internal/resolver/dns" "google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver/manual" + "google.golang.org/protobuf/types/known/durationpb" - durationpb "github.com/golang/protobuf/ptypes/duration" lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" ) diff --git a/balancer/grpclb/grpclb_remote_balancer.go b/balancer/grpclb/grpclb_remote_balancer.go index c8fe1edd8e53..f8b5229c3536 100644 --- a/balancer/grpclb/grpclb_remote_balancer.go +++ b/balancer/grpclb/grpclb_remote_balancer.go @@ -26,7 +26,6 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" @@ -36,8 +35,9 @@ import ( "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" "google.golang.org/grpc/resolver" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" - timestamppb "github.com/golang/protobuf/ptypes/timestamp" lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" ) diff --git a/balancer/grpclb/grpclb_test.go b/balancer/grpclb/grpclb_test.go index 69e842cb435d..619a1cafffa0 100644 --- a/balancer/grpclb/grpclb_test.go +++ b/balancer/grpclb/grpclb_test.go @@ -50,8 +50,8 @@ import ( "google.golang.org/grpc/resolver/manual" "google.golang.org/grpc/serviceconfig" "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/durationpb" - durationpb "github.com/golang/protobuf/ptypes/duration" lbgrpc "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" testgrpc "google.golang.org/grpc/interop/grpc_testing" diff --git a/balancer/rls/config.go b/balancer/rls/config.go index 77b6bdcd1cca..439581c78bc1 100644 --- a/balancer/rls/config.go +++ b/balancer/rls/config.go @@ -25,8 +25,6 @@ import ( "net/url" "time" - "github.com/golang/protobuf/ptypes" - durationpb "github.com/golang/protobuf/ptypes/duration" "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/rls/internal/keys" "google.golang.org/grpc/internal" @@ -35,6 +33,7 @@ import ( "google.golang.org/grpc/resolver" "google.golang.org/grpc/serviceconfig" "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/durationpb" ) const ( @@ -308,5 +307,5 @@ func convertDuration(d *durationpb.Duration) (time.Duration, error) { if d == nil { return 0, nil } - return ptypes.Duration(d) + return d.AsDuration(), d.CheckValid() } diff --git a/binarylog/binarylog_end2end_test.go b/binarylog/binarylog_end2end_test.go index 277c17a10726..f5bf58d37128 100644 --- a/binarylog/binarylog_end2end_test.go +++ b/binarylog/binarylog_end2end_test.go @@ -28,7 +28,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/binarylog" "google.golang.org/grpc/codes" @@ -39,6 +38,7 @@ import ( "google.golang.org/grpc/internal/stubserver" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" testgrpc "google.golang.org/grpc/interop/grpc_testing" diff --git a/credentials/alts/alts_test.go b/credentials/alts/alts_test.go index 1d7de91a7c1a..b607e4525384 100644 --- a/credentials/alts/alts_test.go +++ b/credentials/alts/alts_test.go @@ -28,7 +28,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/alts/internal/handshaker" @@ -42,6 +41,7 @@ import ( testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/peer" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" ) const ( diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index 0ee3d3bae973..f34f6e65f0e3 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -23,8 +23,8 @@ package proto import ( "fmt" - "github.com/golang/protobuf/proto" "google.golang.org/grpc/encoding" + "google.golang.org/protobuf/proto" ) // Name is the name registered for the proto compressor. diff --git a/encoding/proto/proto_benchmark_test.go b/encoding/proto/proto_benchmark_test.go index 8a085e6036b5..8b4cec756342 100644 --- a/encoding/proto/proto_benchmark_test.go +++ b/encoding/proto/proto_benchmark_test.go @@ -22,8 +22,9 @@ import ( "fmt" "testing" - "github.com/golang/protobuf/proto" "google.golang.org/grpc/encoding" + "google.golang.org/protobuf/proto" + pb "google.golang.org/grpc/test/codec_perf" ) diff --git a/examples/go.mod b/examples/go.mod index a500cf907023..683cc06972c9 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -4,7 +4,6 @@ go 1.19 require ( github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa - github.com/golang/protobuf v1.5.3 golang.org/x/oauth2 v0.16.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 google.golang.org/grpc v1.60.1 @@ -19,6 +18,7 @@ require ( github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe // indirect github.com/envoyproxy/go-control-plane v0.12.0 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect + github.com/golang/protobuf v1.5.3 // indirect golang.org/x/net v0.20.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.16.0 // indirect diff --git a/examples/route_guide/server/server.go b/examples/route_guide/server/server.go index 44b2f963516b..e85e5b914cb4 100644 --- a/examples/route_guide/server/server.go +++ b/examples/route_guide/server/server.go @@ -36,11 +36,9 @@ import ( "time" "google.golang.org/grpc" - "google.golang.org/grpc/credentials" "google.golang.org/grpc/examples/data" - - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" pb "google.golang.org/grpc/examples/route_guide/routeguide" ) diff --git a/internal/binarylog/method_logger.go b/internal/binarylog/method_logger.go index 0f31274a3ccc..e8456a77c254 100644 --- a/internal/binarylog/method_logger.go +++ b/internal/binarylog/method_logger.go @@ -25,11 +25,12 @@ import ( "sync/atomic" "time" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/timestamppb" ) type callIDGenerator struct { @@ -88,7 +89,7 @@ func NewTruncatingMethodLogger(h, m uint64) *TruncatingMethodLogger { // in TruncatingMethodLogger as possible. func (ml *TruncatingMethodLogger) Build(c LogEntryConfig) *binlogpb.GrpcLogEntry { m := c.toProto() - timestamp, _ := ptypes.TimestampProto(time.Now()) + timestamp := timestamppb.Now() m.Timestamp = timestamp m.CallId = ml.callID m.SequenceIdWithinCall = ml.idWithinCallGen.next() @@ -178,7 +179,7 @@ func (c *ClientHeader) toProto() *binlogpb.GrpcLogEntry { Authority: c.Authority, } if c.Timeout > 0 { - clientHeader.Timeout = ptypes.DurationProto(c.Timeout) + clientHeader.Timeout = durationpb.New(c.Timeout) } ret := &binlogpb.GrpcLogEntry{ Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER, diff --git a/internal/binarylog/method_logger_test.go b/internal/binarylog/method_logger_test.go index 11255bb338b4..d892a45669d7 100644 --- a/internal/binarylog/method_logger_test.go +++ b/internal/binarylog/method_logger_test.go @@ -26,10 +26,10 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" ) diff --git a/internal/binarylog/sink.go b/internal/binarylog/sink.go index 264de387c2a5..9ea598b14c07 100644 --- a/internal/binarylog/sink.go +++ b/internal/binarylog/sink.go @@ -25,8 +25,8 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" + "google.golang.org/protobuf/proto" ) var ( diff --git a/internal/pretty/pretty.go b/internal/pretty/pretty.go index 7033191375de..52cfab1b93d9 100644 --- a/internal/pretty/pretty.go +++ b/internal/pretty/pretty.go @@ -24,7 +24,6 @@ import ( "encoding/json" "fmt" - "github.com/golang/protobuf/jsonpb" protov1 "github.com/golang/protobuf/proto" "google.golang.org/protobuf/encoding/protojson" protov2 "google.golang.org/protobuf/proto" @@ -38,15 +37,15 @@ const jsonIndent = " " func ToJSON(e any) string { switch ee := e.(type) { case protov1.Message: - mm := jsonpb.Marshaler{Indent: jsonIndent} - ret, err := mm.MarshalToString(ee) + mm := protojson.MarshalOptions{Indent: jsonIndent} + ret, err := mm.Marshal(protov1.MessageV2(ee)) if err != nil { // This may fail for proto.Anys, e.g. for xDS v2, LDS, the v2 // messages are not imported, and this will fail because the message // is not found. return fmt.Sprintf("%+v", ee) } - return ret + return string(ret) case protov2.Message: mm := protojson.MarshalOptions{ Multiline: true, diff --git a/internal/status/status.go b/internal/status/status.go index 03ef2fedd5cb..c7dbc8205952 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -31,10 +31,11 @@ import ( "errors" "fmt" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" spb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc/codes" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/protoadapt" + "google.golang.org/protobuf/types/known/anypb" ) // Status represents an RPC status code, message, and details. It is immutable @@ -130,14 +131,14 @@ func (s *Status) Err() error { // WithDetails returns a new status with the provided details messages appended to the status. // If any errors are encountered, it returns nil and the first error encountered. -func (s *Status) WithDetails(details ...proto.Message) (*Status, error) { +func (s *Status) WithDetails(details ...protoadapt.MessageV1) (*Status, error) { if s.Code() == codes.OK { return nil, errors.New("no error details for status with code OK") } // s.Code() != OK implies that s.Proto() != nil. p := s.Proto() for _, detail := range details { - any, err := ptypes.MarshalAny(detail) + any, err := anypb.New(protoadapt.MessageV2Of(detail)) if err != nil { return nil, err } @@ -154,12 +155,12 @@ func (s *Status) Details() []any { } details := make([]any, 0, len(s.s.Details)) for _, any := range s.s.Details { - detail := &ptypes.DynamicAny{} - if err := ptypes.UnmarshalAny(any, detail); err != nil { + detail, err := any.UnmarshalNew() + if err != nil { details = append(details, err) continue } - details = append(details, detail.Message) + details = append(details, detail) } return details } diff --git a/internal/testutils/marshal_any.go b/internal/testutils/marshal_any.go index c84096eb2548..12ce83277da4 100644 --- a/internal/testutils/marshal_any.go +++ b/internal/testutils/marshal_any.go @@ -20,8 +20,7 @@ package testutils import ( "testing" - "github.com/golang/protobuf/proto" - "google.golang.org/protobuf/protoadapt" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" ) @@ -30,7 +29,7 @@ import ( func MarshalAny(t *testing.T, m proto.Message) *anypb.Any { t.Helper() - a, err := anypb.New(protoadapt.MessageV2Of(m)) + a, err := anypb.New(m) if err != nil { t.Fatalf("Failed to marshal proto %+v into an Any: %v", m, err) } diff --git a/internal/testutils/status_equal.go b/internal/testutils/status_equal.go index dfd647336df8..961e5a3d0d82 100644 --- a/internal/testutils/status_equal.go +++ b/internal/testutils/status_equal.go @@ -19,8 +19,8 @@ package testutils import ( - "github.com/golang/protobuf/proto" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" ) // StatusErrEqual returns true iff both err1 and err2 wrap status.Status errors diff --git a/internal/testutils/status_equal_test.go b/internal/testutils/status_equal_test.go index 850bf0fde89f..0c1db3c648ca 100644 --- a/internal/testutils/status_equal_test.go +++ b/internal/testutils/status_equal_test.go @@ -21,11 +21,11 @@ package testutils import ( "testing" - anypb "github.com/golang/protobuf/ptypes/any" spb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal/grpctest" "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/anypb" ) type s struct { diff --git a/internal/testutils/xds/e2e/clientresources.go b/internal/testutils/xds/e2e/clientresources.go index 64accf09cd78..347ea8042315 100644 --- a/internal/testutils/xds/e2e/clientresources.go +++ b/internal/testutils/xds/e2e/clientresources.go @@ -23,11 +23,10 @@ import ( "net" "strconv" - "google.golang.org/protobuf/protoadapt" - "github.com/envoyproxy/go-control-plane/pkg/wellknown" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/wrapperspb" v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" @@ -39,7 +38,6 @@ import ( v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" - wrapperspb "github.com/golang/protobuf/ptypes/wrappers" ) const ( @@ -130,7 +128,7 @@ func DefaultClientListener(target, routeName string) *v3listenerpb.Listener { } func marshalAny(m proto.Message) *anypb.Any { - a, err := anypb.New(protoadapt.MessageV2Of(m)) + a, err := anypb.New(m) if err != nil { panic(fmt.Sprintf("anypb.New(%+v) failed: %v", m, err)) } diff --git a/internal/testutils/xds/fakeserver/server.go b/internal/testutils/xds/fakeserver/server.go index e2f2fb39e0dd..241f993642a1 100644 --- a/internal/testutils/xds/fakeserver/server.go +++ b/internal/testutils/xds/fakeserver/server.go @@ -29,11 +29,11 @@ import ( "net" "time" - "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" v3discoverygrpc "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" diff --git a/internal/transport/handler_server.go b/internal/transport/handler_server.go index a9d70e2a16c3..bd39ff9a2290 100644 --- a/internal/transport/handler_server.go +++ b/internal/transport/handler_server.go @@ -35,7 +35,6 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" "golang.org/x/net/http2" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" @@ -45,6 +44,7 @@ import ( "google.golang.org/grpc/peer" "google.golang.org/grpc/stats" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" ) // NewServerHandlerTransport returns a ServerTransport handling gRPC from diff --git a/internal/transport/handler_server_test.go b/internal/transport/handler_server_test.go index acd5e6e33f87..9f96db691ed8 100644 --- a/internal/transport/handler_server_test.go +++ b/internal/transport/handler_server_test.go @@ -31,12 +31,13 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/ptypes/duration" epb "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/protoadapt" + "google.golang.org/protobuf/types/known/durationpb" ) func (s) TestHandlerTransport_NewServerHandlerTransport(t *testing.T) { @@ -448,9 +449,9 @@ func testHandlerTransportHandleStreams(t *testing.T, handleStream func(st *handl } func (s) TestHandlerTransport_HandleStreams_ErrDetails(t *testing.T) { - errDetails := []proto.Message{ + errDetails := []protoadapt.MessageV1{ &epb.RetryInfo{ - RetryDelay: &dpb.Duration{Seconds: 60}, + RetryDelay: &durationpb.Duration{Seconds: 60}, }, &epb.ResourceInfo{ ResourceType: "foo bar", diff --git a/internal/transport/http2_server.go b/internal/transport/http2_server.go index f6bac0e8a00d..5d49403c75a7 100644 --- a/internal/transport/http2_server.go +++ b/internal/transport/http2_server.go @@ -32,13 +32,13 @@ import ( "sync/atomic" "time" - "github.com/golang/protobuf/proto" "golang.org/x/net/http2" "golang.org/x/net/http2/hpack" "google.golang.org/grpc/internal/grpclog" "google.golang.org/grpc/internal/grpcutil" "google.golang.org/grpc/internal/pretty" "google.golang.org/grpc/internal/syscall" + "google.golang.org/protobuf/proto" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" diff --git a/internal/xds/rbac/rbac_engine_test.go b/internal/xds/rbac/rbac_engine_test.go index d0c3ae7af3e8..94f12e92400a 100644 --- a/internal/xds/rbac/rbac_engine_test.go +++ b/internal/xds/rbac/rbac_engine_test.go @@ -35,7 +35,6 @@ import ( v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" v3matcherpb "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" - wrapperspb "github.com/golang/protobuf/ptypes/wrappers" "google.golang.org/grpc" "google.golang.org/grpc/authz/audit" "google.golang.org/grpc/codes" @@ -46,6 +45,7 @@ import ( "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/wrapperspb" ) type s struct { diff --git a/interop/test_utils.go b/interop/test_utils.go index 7b597cae40eb..83e656832e28 100644 --- a/interop/test_utils.go +++ b/interop/test_utils.go @@ -33,7 +33,6 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "google.golang.org/grpc" @@ -44,6 +43,7 @@ import ( "google.golang.org/grpc/orca" "google.golang.org/grpc/peer" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" v3orcapb "github.com/cncf/xds/go/xds/data/orca/v3" testgrpc "google.golang.org/grpc/interop/grpc_testing" diff --git a/orca/call_metrics_test.go b/orca/call_metrics_test.go index 474ac710b55b..860885aec46e 100644 --- a/orca/call_metrics_test.go +++ b/orca/call_metrics_test.go @@ -24,7 +24,6 @@ import ( "io" "testing" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -33,6 +32,7 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/orca" "google.golang.org/grpc/orca/internal" + "google.golang.org/protobuf/proto" v3orcapb "github.com/cncf/xds/go/xds/data/orca/v3" testgrpc "google.golang.org/grpc/interop/grpc_testing" diff --git a/orca/orca_test.go b/orca/orca_test.go index 4f85e7b01592..ce5b7bbefafe 100644 --- a/orca/orca_test.go +++ b/orca/orca_test.go @@ -22,12 +22,12 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "google.golang.org/grpc/internal/grpctest" "google.golang.org/grpc/internal/pretty" "google.golang.org/grpc/metadata" "google.golang.org/grpc/orca/internal" + "google.golang.org/protobuf/proto" v3orcapb "github.com/cncf/xds/go/xds/data/orca/v3" ) diff --git a/orca/producer_test.go b/orca/producer_test.go index 5d29e1a0d322..ece8a8db7145 100644 --- a/orca/producer_test.go +++ b/orca/producer_test.go @@ -23,7 +23,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/roundrobin" @@ -36,6 +35,7 @@ import ( "google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver/manual" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" v3orcapb "github.com/cncf/xds/go/xds/data/orca/v3" v3orcaservicegrpc "github.com/cncf/xds/go/xds/service/orca/v3" diff --git a/orca/service_test.go b/orca/service_test.go index 9c4defbe266b..0ac3d6420db2 100644 --- a/orca/service_test.go +++ b/orca/service_test.go @@ -25,7 +25,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -33,6 +32,7 @@ import ( "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/orca" "google.golang.org/grpc/orca/internal" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" v3orcapb "github.com/cncf/xds/go/xds/data/orca/v3" diff --git a/rpc_util_test.go b/rpc_util_test.go index 84f2348655b9..3f84b98395fb 100644 --- a/rpc_util_test.go +++ b/rpc_util_test.go @@ -26,7 +26,6 @@ import ( "reflect" "testing" - "github.com/golang/protobuf/proto" "google.golang.org/grpc/codes" "google.golang.org/grpc/encoding" protoenc "google.golang.org/grpc/encoding/proto" @@ -34,6 +33,7 @@ import ( "google.golang.org/grpc/internal/transport" "google.golang.org/grpc/status" perfpb "google.golang.org/grpc/test/codec_perf" + "google.golang.org/protobuf/proto" ) type fullReader struct { diff --git a/stats/stats_test.go b/stats/stats_test.go index 09b7acaa4a3c..47c0ab326f69 100644 --- a/stats/stats_test.go +++ b/stats/stats_test.go @@ -28,7 +28,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/internal" @@ -38,6 +37,7 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/stats" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" testgrpc "google.golang.org/grpc/interop/grpc_testing" testpb "google.golang.org/grpc/interop/grpc_testing" diff --git a/status/status_ext_test.go b/status/status_ext_test.go index 5fc0086c9a29..659d10d0deb0 100644 --- a/status/status_ext_test.go +++ b/status/status_ext_test.go @@ -25,7 +25,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -34,6 +33,8 @@ import ( "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/protoadapt" testpb "google.golang.org/grpc/interop/grpc_testing" ) @@ -48,7 +49,7 @@ func Test(t *testing.T) { grpctest.RunSubTests(t, s{}) } -func errWithDetails(t *testing.T, s *status.Status, details ...proto.Message) error { +func errWithDetails(t *testing.T, s *status.Status, details ...protoadapt.MessageV1) error { t.Helper() res, err := s.WithDetails(details...) if err != nil { diff --git a/status/status_test.go b/status/status_test.go index d21a862f3637..bee7ceed8d82 100644 --- a/status/status_test.go +++ b/status/status_test.go @@ -24,14 +24,16 @@ import ( "fmt" "testing" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" - apb "github.com/golang/protobuf/ptypes/any" - dpb "github.com/golang/protobuf/ptypes/duration" "github.com/google/go-cmp/cmp" cpb "google.golang.org/genproto/googleapis/rpc/code" epb "google.golang.org/genproto/googleapis/rpc/errdetails" spb "google.golang.org/genproto/googleapis/rpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/protoadapt" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/runtime/protoimpl" + "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal/grpctest" @@ -73,7 +75,7 @@ func (s) TestFromToProto(t *testing.T) { s := &spb.Status{ Code: int32(codes.Internal), Message: "test test test", - Details: []*apb.Any{{TypeUrl: "foo", Value: []byte{3, 2, 1}}}, + Details: []*anypb.Any{{TypeUrl: "foo", Value: []byte{3, 2, 1}}}, } err := FromProto(s) @@ -148,7 +150,7 @@ func (s) TestFromErrorOK(t *testing.T) { type customError struct { Code codes.Code Message string - Details []*apb.Any + Details []*anypb.Any } func (c customError) Error() string { @@ -165,7 +167,7 @@ func (c customError) GRPCStatus() *Status { func (s) TestFromErrorImplementsInterface(t *testing.T) { code, message := codes.Internal, "test description" - details := []*apb.Any{{ + details := []*anypb.Any{{ TypeUrl: "testUrl", Value: []byte("testValue"), }} @@ -305,7 +307,7 @@ func (s) TestConvertUnknownError(t *testing.T) { func (s) TestStatus_ErrorDetails(t *testing.T) { tests := []struct { code codes.Code - details []proto.Message + details []protoadapt.MessageV1 }{ { code: codes.NotFound, @@ -313,7 +315,7 @@ func (s) TestStatus_ErrorDetails(t *testing.T) { }, { code: codes.NotFound, - details: []proto.Message{ + details: []protoadapt.MessageV1{ &epb.ResourceInfo{ ResourceType: "book", ResourceName: "projects/1234/books/5678", @@ -323,7 +325,7 @@ func (s) TestStatus_ErrorDetails(t *testing.T) { }, { code: codes.Internal, - details: []proto.Message{ + details: []protoadapt.MessageV1{ &epb.DebugInfo{ StackEntries: []string{ "first stack", @@ -334,9 +336,9 @@ func (s) TestStatus_ErrorDetails(t *testing.T) { }, { code: codes.Unavailable, - details: []proto.Message{ + details: []protoadapt.MessageV1{ &epb.RetryInfo{ - RetryDelay: &dpb.Duration{Seconds: 60}, + RetryDelay: &durationpb.Duration{Seconds: 60}, }, &epb.ResourceInfo{ ResourceType: "book", @@ -354,7 +356,7 @@ func (s) TestStatus_ErrorDetails(t *testing.T) { } details := s.Details() for i := range details { - if !proto.Equal(details[i].(proto.Message), tc.details[i]) { + if !proto.Equal(details[i].(protoreflect.ProtoMessage), tc.details[i].(protoreflect.ProtoMessage)) { t.Fatalf("(%v).Details()[%d] = %+v, want %+v", str(s), i, details[i], tc.details[i]) } } @@ -394,7 +396,7 @@ func (s) TestStatus_ErrorDetails_Fail(t *testing.T) { { FromProto(&spb.Status{ Code: int32(cpb.Code_CANCELLED), - Details: []*apb.Any{ + Details: []*anypb.Any{ { TypeUrl: "", Value: []byte{}, @@ -407,7 +409,7 @@ func (s) TestStatus_ErrorDetails_Fail(t *testing.T) { }, }), []any{ - errors.New(`message type url "" is invalid`), + protoimpl.X.NewError("invalid empty type URL"), &epb.ResourceInfo{ ResourceType: "book", ResourceName: "projects/1234/books/5678", @@ -439,10 +441,10 @@ func str(s *Status) string { } // mustMarshalAny converts a protobuf message to an any. -func mustMarshalAny(msg proto.Message) *apb.Any { - any, err := ptypes.MarshalAny(msg) +func mustMarshalAny(msg proto.Message) *anypb.Any { + any, err := anypb.New(msg) if err != nil { - panic(fmt.Sprintf("ptypes.MarshalAny(%+v) failed: %v", msg, err)) + panic(fmt.Sprintf("anypb.New(%+v) failed: %v", msg, err)) } return any } diff --git a/test/end2end_test.go b/test/end2end_test.go index 97a7f1812553..001a1228a25b 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -41,7 +41,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "golang.org/x/net/http2" "golang.org/x/net/http2/hpack" "google.golang.org/grpc" @@ -71,12 +70,13 @@ import ( "google.golang.org/grpc/test/bufconn" "google.golang.org/grpc/testdata" - anypb "github.com/golang/protobuf/ptypes/any" spb "google.golang.org/genproto/googleapis/rpc/status" healthgrpc "google.golang.org/grpc/health/grpc_health_v1" healthpb "google.golang.org/grpc/health/grpc_health_v1" testgrpc "google.golang.org/grpc/interop/grpc_testing" testpb "google.golang.org/grpc/interop/grpc_testing" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" _ "google.golang.org/grpc/encoding/gzip" ) diff --git a/test/retry_test.go b/test/retry_test.go index 49becb359097..e86a8a951153 100644 --- a/test/retry_test.go +++ b/test/retry_test.go @@ -30,7 +30,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" @@ -39,6 +38,7 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/stats" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" testgrpc "google.golang.org/grpc/interop/grpc_testing" testpb "google.golang.org/grpc/interop/grpc_testing" diff --git a/test/tools/go.mod b/test/tools/go.mod index 874d8fa6dc2a..0a8e845fb87e 100644 --- a/test/tools/go.mod +++ b/test/tools/go.mod @@ -4,8 +4,8 @@ go 1.19 require ( github.com/client9/misspell v0.3.4 - github.com/golang/protobuf v1.5.3 - golang.org/x/tools v0.17.0 + golang.org/x/tools v0.14.0 + google.golang.org/protobuf v1.32.0 honnef.co/go/tools v0.4.6 ) @@ -13,5 +13,5 @@ require ( github.com/BurntSushi/toml v1.3.2 // indirect golang.org/x/exp/typeparams v0.0.0-20240119083558-1b970713d09a // indirect golang.org/x/mod v0.14.0 // indirect - google.golang.org/protobuf v1.32.0 // indirect + golang.org/x/sys v0.13.0 // indirect ) diff --git a/test/tools/go.sum b/test/tools/go.sum index dd35dd3ee5cb..d509320dcdc3 100644 --- a/test/tools/go.sum +++ b/test/tools/go.sum @@ -2,22 +2,17 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8 github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= golang.org/x/exp/typeparams v0.0.0-20240119083558-1b970713d09a h1:8qmSSA8Gz/1kTrCe0nqR0R3Gb/NDhykzWw2q2mWZydM= golang.org/x/exp/typeparams v0.0.0-20240119083558-1b970713d09a/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= +golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= honnef.co/go/tools v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8= diff --git a/test/tools/tools.go b/test/tools/tools.go index d585cb6eb9aa..a192fd37cfbe 100644 --- a/test/tools/tools.go +++ b/test/tools/tools.go @@ -27,7 +27,7 @@ package tools import ( _ "github.com/client9/misspell/cmd/misspell" - _ "github.com/golang/protobuf/protoc-gen-go" _ "golang.org/x/tools/cmd/goimports" + _ "google.golang.org/protobuf/cmd/protoc-gen-go" _ "honnef.co/go/tools/cmd/staticcheck" ) diff --git a/test/xds/xds_client_custom_lb_test.go b/test/xds/xds_client_custom_lb_test.go index 1bfc2e1eb39b..6128b02f0b4f 100644 --- a/test/xds/xds_client_custom_lb_test.go +++ b/test/xds/xds_client_custom_lb_test.go @@ -45,10 +45,10 @@ import ( v3leastrequestpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/least_request/v3" v3roundrobinpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/round_robin/v3" v3wrrlocalitypb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/wrr_locality/v3" - "github.com/golang/protobuf/proto" - structpb "github.com/golang/protobuf/ptypes/struct" testgrpc "google.golang.org/grpc/interop/grpc_testing" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/wrapperspb" ) diff --git a/test/xds/xds_server_rbac_test.go b/test/xds/xds_server_rbac_test.go index 5528baa00395..953d88f96fc5 100644 --- a/test/xds/xds_server_rbac_test.go +++ b/test/xds/xds_server_rbac_test.go @@ -40,6 +40,7 @@ import ( "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/wrapperspb" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" @@ -48,7 +49,6 @@ import ( rpb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/rbac/v3" v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" v3matcherpb "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" - wrapperspb "github.com/golang/protobuf/ptypes/wrappers" testgrpc "google.golang.org/grpc/interop/grpc_testing" testpb "google.golang.org/grpc/interop/grpc_testing" ) diff --git a/xds/csds/csds_e2e_test.go b/xds/csds/csds_e2e_test.go index 2f328bc83414..83bb0a4dd544 100644 --- a/xds/csds/csds_e2e_test.go +++ b/xds/csds/csds_e2e_test.go @@ -27,7 +27,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "github.com/google/uuid" "google.golang.org/grpc" @@ -39,6 +38,7 @@ import ( "google.golang.org/grpc/xds/csds" "google.golang.org/grpc/xds/internal/xdsclient" "google.golang.org/grpc/xds/internal/xdsclient/xdsresource" + "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/testing/protocmp" "google.golang.org/protobuf/types/known/anypb" @@ -393,7 +393,7 @@ func checkClientStatusResponse(stream v3statuspbgrpc.ClientStatusDiscoveryServic } if n := len(resp.Config); n != 1 { - return fmt.Errorf("got %d configs, want 1: %v", n, proto.MarshalTextString(resp)) + return fmt.Errorf("got %d configs, want 1: %v", n, prototext.Format(resp)) } if diff := cmp.Diff(resp.Config[0].GenericXdsConfigs, want, cmpOpts); diff != "" { @@ -456,6 +456,6 @@ func (s) TestCSDSNoXDSClient(t *testing.T) { t.Fatalf("Failed to recv ClientStatusResponse: %v", err) } if n := len(r.Config); n != 0 { - t.Fatalf("got %d configs, want 0: %v", n, proto.MarshalTextString(r)) + t.Fatalf("got %d configs, want 0: %v", n, prototext.Format(r)) } } diff --git a/xds/internal/clusterspecifier/cluster_specifier.go b/xds/internal/clusterspecifier/cluster_specifier.go index 8fcb83cdbb1e..f81e2cab0f8c 100644 --- a/xds/internal/clusterspecifier/cluster_specifier.go +++ b/xds/internal/clusterspecifier/cluster_specifier.go @@ -21,7 +21,7 @@ package clusterspecifier import ( - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) // BalancerConfig is the Go Native JSON representation of a balancer diff --git a/xds/internal/clusterspecifier/rls/rls.go b/xds/internal/clusterspecifier/rls/rls.go index 46238ca62771..74abfec1fa88 100644 --- a/xds/internal/clusterspecifier/rls/rls.go +++ b/xds/internal/clusterspecifier/rls/rls.go @@ -23,13 +23,12 @@ import ( "encoding/json" "fmt" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" "google.golang.org/grpc/balancer" "google.golang.org/grpc/internal" rlspb "google.golang.org/grpc/internal/proto/grpc_lookup_v1" "google.golang.org/grpc/xds/internal/clusterspecifier" "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" ) @@ -72,7 +71,7 @@ func (rls) ParseClusterSpecifierConfig(cfg proto.Message) (clusterspecifier.Bala } rlcs := new(rlspb.RouteLookupClusterSpecifier) - if err := ptypes.UnmarshalAny(any, rlcs); err != nil { + if err := any.UnmarshalTo(rlcs); err != nil { return nil, fmt.Errorf("rls_csp: error parsing config %v: %v", cfg, err) } rlcJSON, err := protojson.Marshal(rlcs.GetRouteLookupConfig()) diff --git a/xds/internal/clusterspecifier/rls/rls_test.go b/xds/internal/clusterspecifier/rls/rls_test.go index 3297aa83a9af..8f09ac152b90 100644 --- a/xds/internal/clusterspecifier/rls/rls_test.go +++ b/xds/internal/clusterspecifier/rls/rls_test.go @@ -22,13 +22,13 @@ import ( "encoding/json" "testing" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/grpc/internal/grpctest" rlspb "google.golang.org/grpc/internal/proto/grpc_lookup_v1" "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/xds/internal/clusterspecifier" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" _ "google.golang.org/grpc/balancer/rls" // Register the RLS LB policy. diff --git a/xds/internal/httpfilter/fault/fault.go b/xds/internal/httpfilter/fault/fault.go index aa329d13ac30..3ad93e27b1d3 100644 --- a/xds/internal/httpfilter/fault/fault.go +++ b/xds/internal/httpfilter/fault/fault.go @@ -28,14 +28,13 @@ import ( "sync/atomic" "time" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal/grpcrand" iresolver "google.golang.org/grpc/internal/resolver" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/grpc/xds/internal/httpfilter" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" cpb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/common/fault/v3" @@ -87,7 +86,7 @@ func parseConfig(cfg proto.Message) (httpfilter.FilterConfig, error) { return nil, fmt.Errorf("fault: error parsing config %v: unknown type %T", cfg, cfg) } msg := new(fpb.HTTPFault) - if err := ptypes.UnmarshalAny(any, msg); err != nil { + if err := any.UnmarshalTo(msg); err != nil { return nil, fmt.Errorf("fault: error parsing config %v: %v", cfg, err) } return config{config: msg}, nil diff --git a/xds/internal/httpfilter/fault/fault_test.go b/xds/internal/httpfilter/fault/fault_test.go index 34300a419546..94e0f0c00be6 100644 --- a/xds/internal/httpfilter/fault/fault_test.go +++ b/xds/internal/httpfilter/fault/fault_test.go @@ -31,7 +31,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/ptypes" "github.com/google/uuid" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -43,6 +42,7 @@ import ( "google.golang.org/grpc/internal/testutils/xds/e2e" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/wrapperspb" v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" @@ -219,7 +219,7 @@ func (s) TestFaultInjection_Unary(t *testing.T) { cfgs: []*fpb.HTTPFault{{ Delay: &cpb.FaultDelay{ Percentage: &tpb.FractionalPercent{Numerator: 100, Denominator: tpb.FractionalPercent_HUNDRED}, - FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: ptypes.DurationProto(time.Second)}, + FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: durationpb.New(time.Second)}, }, }}, randOutInc: 5, @@ -233,7 +233,7 @@ func (s) TestFaultInjection_Unary(t *testing.T) { cfgs: []*fpb.HTTPFault{{ Delay: &cpb.FaultDelay{ Percentage: &tpb.FractionalPercent{Numerator: 1000, Denominator: tpb.FractionalPercent_TEN_THOUSAND}, - FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: ptypes.DurationProto(time.Second)}, + FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: durationpb.New(time.Second)}, }, }}, randOutInc: 500, @@ -257,7 +257,7 @@ func (s) TestFaultInjection_Unary(t *testing.T) { cfgs: []*fpb.HTTPFault{{ Delay: &cpb.FaultDelay{ Percentage: &tpb.FractionalPercent{Numerator: 80, Denominator: tpb.FractionalPercent_HUNDRED}, - FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: ptypes.DurationProto(3 * time.Second)}, + FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: durationpb.New(3 * time.Second)}, }, Abort: &fpb.FaultAbort{ Percentage: &tpb.FractionalPercent{Numerator: 50, Denominator: tpb.FractionalPercent_HUNDRED}, @@ -457,7 +457,7 @@ func (s) TestFaultInjection_Unary(t *testing.T) { }, { Delay: &cpb.FaultDelay{ Percentage: &tpb.FractionalPercent{Numerator: 80, Denominator: tpb.FractionalPercent_HUNDRED}, - FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: ptypes.DurationProto(time.Second)}, + FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: durationpb.New(time.Second)}, }, }}, randOutInc: 10, @@ -506,7 +506,8 @@ func (s) TestFaultInjection_Unary(t *testing.T) { SecLevel: e2e.SecurityLevelNone, }) hcm := new(v3httppb.HttpConnectionManager) - err := ptypes.UnmarshalAny(resources.Listeners[0].GetApiListener().GetApiListener(), hcm) + lis := resources.Listeners[0].GetApiListener().GetApiListener() + err := lis.UnmarshalTo(hcm) if err != nil { t.Fatal(err) } @@ -570,7 +571,8 @@ func (s) TestFaultInjection_MaxActiveFaults(t *testing.T) { SecLevel: e2e.SecurityLevelNone, }) hcm := new(v3httppb.HttpConnectionManager) - err := ptypes.UnmarshalAny(resources.Listeners[0].GetApiListener().GetApiListener(), hcm) + lis := resources.Listeners[0].GetApiListener().GetApiListener() + err := lis.UnmarshalTo(hcm) if err != nil { t.Fatal(err) } @@ -588,7 +590,7 @@ func (s) TestFaultInjection_MaxActiveFaults(t *testing.T) { MaxActiveFaults: wrapperspb.UInt32(2), Delay: &cpb.FaultDelay{ Percentage: &tpb.FractionalPercent{Numerator: 100, Denominator: tpb.FractionalPercent_HUNDRED}, - FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: ptypes.DurationProto(time.Second)}, + FaultDelaySecifier: &cpb.FaultDelay_FixedDelay{FixedDelay: durationpb.New(time.Second)}, }, })}, hcm.HttpFilters...) diff --git a/xds/internal/httpfilter/httpfilter.go b/xds/internal/httpfilter/httpfilter.go index dd9a278389b5..4402f0ebff5d 100644 --- a/xds/internal/httpfilter/httpfilter.go +++ b/xds/internal/httpfilter/httpfilter.go @@ -21,8 +21,8 @@ package httpfilter import ( - "github.com/golang/protobuf/proto" iresolver "google.golang.org/grpc/internal/resolver" + "google.golang.org/protobuf/proto" ) // FilterConfig represents an opaque data structure holding configuration for a diff --git a/xds/internal/httpfilter/rbac/rbac.go b/xds/internal/httpfilter/rbac/rbac.go index 21fa2f4cf324..37de3a39b64f 100644 --- a/xds/internal/httpfilter/rbac/rbac.go +++ b/xds/internal/httpfilter/rbac/rbac.go @@ -25,12 +25,11 @@ import ( "fmt" "strings" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" "google.golang.org/grpc/internal" "google.golang.org/grpc/internal/resolver" "google.golang.org/grpc/internal/xds/rbac" "google.golang.org/grpc/xds/internal/httpfilter" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" v3rbacpb "github.com/envoyproxy/go-control-plane/envoy/config/rbac/v3" @@ -147,7 +146,7 @@ func (builder) ParseFilterConfig(cfg proto.Message) (httpfilter.FilterConfig, er return nil, fmt.Errorf("rbac: error parsing config %v: unknown type %T", cfg, cfg) } msg := new(rpb.RBAC) - if err := ptypes.UnmarshalAny(any, msg); err != nil { + if err := any.UnmarshalTo(msg); err != nil { return nil, fmt.Errorf("rbac: error parsing config %v: %v", cfg, err) } return parseConfig(msg) @@ -162,7 +161,7 @@ func (builder) ParseFilterConfigOverride(override proto.Message) (httpfilter.Fil return nil, fmt.Errorf("rbac: error parsing override config %v: unknown type %T", override, override) } msg := new(rpb.RBACPerRoute) - if err := ptypes.UnmarshalAny(any, msg); err != nil { + if err := any.UnmarshalTo(msg); err != nil { return nil, fmt.Errorf("rbac: error parsing override config %v: %v", override, err) } return parseConfig(msg.Rbac) diff --git a/xds/internal/httpfilter/router/router.go b/xds/internal/httpfilter/router/router.go index 1ac6518170fc..1675ec86ec11 100644 --- a/xds/internal/httpfilter/router/router.go +++ b/xds/internal/httpfilter/router/router.go @@ -22,10 +22,9 @@ package router import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" iresolver "google.golang.org/grpc/internal/resolver" "google.golang.org/grpc/xds/internal/httpfilter" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" pb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3" @@ -60,7 +59,7 @@ func (builder) ParseFilterConfig(cfg proto.Message) (httpfilter.FilterConfig, er return nil, fmt.Errorf("router: error parsing config %v: unknown type %T", cfg, cfg) } msg := new(pb.Router) - if err := ptypes.UnmarshalAny(any, msg); err != nil { + if err := any.UnmarshalTo(msg); err != nil { return nil, fmt.Errorf("router: error parsing config %v: %v", cfg, err) } return config{}, nil diff --git a/xds/internal/resolver/cluster_specifier_plugin_test.go b/xds/internal/resolver/cluster_specifier_plugin_test.go index aac5b7730d44..007a0af1afaf 100644 --- a/xds/internal/resolver/cluster_specifier_plugin_test.go +++ b/xds/internal/resolver/cluster_specifier_plugin_test.go @@ -24,7 +24,6 @@ import ( "fmt" "testing" - "github.com/golang/protobuf/proto" "github.com/google/uuid" "google.golang.org/grpc/balancer" iresolver "google.golang.org/grpc/internal/resolver" @@ -34,7 +33,7 @@ import ( "google.golang.org/grpc/serviceconfig" "google.golang.org/grpc/xds/internal/balancer/clustermanager" "google.golang.org/grpc/xds/internal/clusterspecifier" - protov2 "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -97,7 +96,7 @@ func (testClusterSpecifierPlugin) ParseClusterSpecifierConfig(cfg proto.Message) return nil, fmt.Errorf("testClusterSpecifierPlugin: error parsing config %v: got type %T, want *anypb.Any", cfg, cfg) } lbCfg := new(wrapperspb.StringValue) - if err := anypb.UnmarshalTo(anyp, lbCfg, protov2.UnmarshalOptions{}); err != nil { + if err := anypb.UnmarshalTo(anyp, lbCfg, proto.UnmarshalOptions{}); err != nil { return nil, fmt.Errorf("testClusterSpecifierPlugin: error parsing config %v: %v", cfg, err) } return []map[string]any{{"csp_experimental": cspBalancerConfig{ArbitraryField: lbCfg.GetValue()}}}, nil diff --git a/xds/internal/resolver/xds_resolver_test.go b/xds/internal/resolver/xds_resolver_test.go index bb108fa69052..1a0ca4ed5b40 100644 --- a/xds/internal/resolver/xds_resolver_test.go +++ b/xds/internal/resolver/xds_resolver_test.go @@ -27,7 +27,6 @@ import ( xxhash "github.com/cespare/xxhash/v2" "github.com/envoyproxy/go-control-plane/pkg/wellknown" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "github.com/google/uuid" "google.golang.org/grpc/codes" @@ -50,6 +49,7 @@ import ( "google.golang.org/grpc/xds/internal/xdsclient" "google.golang.org/grpc/xds/internal/xdsclient/bootstrap" "google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/structpb" diff --git a/xds/internal/testutils/protos.go b/xds/internal/testutils/protos.go index fc3cdf307fcd..3d1906b6212d 100644 --- a/xds/internal/testutils/protos.go +++ b/xds/internal/testutils/protos.go @@ -26,8 +26,8 @@ import ( v2endpointpb "github.com/envoyproxy/go-control-plane/envoy/api/v2/endpoint" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v2typepb "github.com/envoyproxy/go-control-plane/envoy/type" - wrapperspb "github.com/golang/protobuf/ptypes/wrappers" "google.golang.org/grpc/xds/internal" + "google.golang.org/protobuf/types/known/wrapperspb" ) // EmptyNodeProtoV2 is a v2 Node proto with no fields set. diff --git a/xds/internal/xdsclient/bootstrap/bootstrap_test.go b/xds/internal/xdsclient/bootstrap/bootstrap_test.go index a1138e2363d5..8933f4303bc8 100644 --- a/xds/internal/xdsclient/bootstrap/bootstrap_test.go +++ b/xds/internal/xdsclient/bootstrap/bootstrap_test.go @@ -25,7 +25,6 @@ import ( "os" "testing" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/grpc" @@ -33,9 +32,10 @@ import ( "google.golang.org/grpc/internal" "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/xds/bootstrap" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/structpb" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" - structpb "github.com/golang/protobuf/ptypes/struct" ) var ( diff --git a/xds/internal/xdsclient/loadreport_test.go b/xds/internal/xdsclient/loadreport_test.go index 06e58acdd2dc..dba99d9d26e2 100644 --- a/xds/internal/xdsclient/loadreport_test.go +++ b/xds/internal/xdsclient/loadreport_test.go @@ -34,7 +34,7 @@ import ( v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" v3lrspb "github.com/envoyproxy/go-control-plane/envoy/service/load_stats/v3" - durationpb "github.com/golang/protobuf/ptypes/duration" + "google.golang.org/protobuf/types/known/durationpb" ) const ( diff --git a/xds/internal/xdsclient/transport/loadreport.go b/xds/internal/xdsclient/transport/loadreport.go index 4b8ca29ce93f..289fd62cbc75 100644 --- a/xds/internal/xdsclient/transport/loadreport.go +++ b/xds/internal/xdsclient/transport/loadreport.go @@ -24,13 +24,13 @@ import ( "io" "time" - "github.com/golang/protobuf/ptypes" "google.golang.org/grpc/internal/backoff" "google.golang.org/grpc/internal/grpcsync" "google.golang.org/grpc/internal/pretty" "google.golang.org/grpc/xds/internal" "google.golang.org/grpc/xds/internal/xdsclient/load" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/durationpb" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" @@ -170,10 +170,11 @@ func (t *Transport) recvFirstLoadStatsResponse(stream lrsStream) ([]string, time t.logger.Infof("Received first LoadStatsResponse: %s", pretty.ToJSON(resp)) } - interval, err := ptypes.Duration(resp.GetLoadReportingInterval()) - if err != nil { + rInterval := resp.GetLoadReportingInterval() + if rInterval.CheckValid() != nil { return nil, 0, fmt.Errorf("invalid load_reporting_interval: %v", err) } + interval := rInterval.AsDuration() if resp.ReportEndpointGranularity { // TODO(easwars): Support per endpoint loads. @@ -233,7 +234,7 @@ func (t *Transport) sendLoadStatsRequest(stream lrsStream, loads []*load.Data) e UpstreamLocalityStats: localityStats, TotalDroppedRequests: sd.TotalDrops, DroppedRequests: droppedReqs, - LoadReportInterval: ptypes.DurationProto(sd.ReportInterval), + LoadReportInterval: durationpb.New(sd.ReportInterval), }) } diff --git a/xds/internal/xdsclient/xdslbregistry/converter/converter.go b/xds/internal/xdsclient/xdslbregistry/converter/converter.go index b520e37c7ca8..076ae8644f88 100644 --- a/xds/internal/xdsclient/xdslbregistry/converter/converter.go +++ b/xds/internal/xdsclient/xdslbregistry/converter/converter.go @@ -27,7 +27,6 @@ import ( "fmt" "strings" - "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/leastrequest" @@ -38,6 +37,8 @@ import ( "google.golang.org/grpc/xds/internal/balancer/ringhash" "google.golang.org/grpc/xds/internal/balancer/wrrlocality" "google.golang.org/grpc/xds/internal/xdsclient/xdslbregistry" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/structpb" v1xdsudpatypepb "github.com/cncf/xds/go/udpa/type/v1" v3xdsxdstypepb "github.com/cncf/xds/go/xds/type/v3" @@ -46,7 +47,6 @@ import ( v3pickfirstpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/pick_first/v3" v3ringhashpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/ring_hash/v3" v3wrrlocalitypb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/wrr_locality/v3" - structpb "github.com/golang/protobuf/ptypes/struct" ) func init() { diff --git a/xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go b/xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go index 5beaee5fd953..d3a7bef0942d 100644 --- a/xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go +++ b/xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go @@ -24,7 +24,6 @@ import ( "strings" "testing" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" _ "google.golang.org/grpc/balancer/roundrobin" "google.golang.org/grpc/internal/balancer/stub" @@ -36,7 +35,9 @@ import ( _ "google.golang.org/grpc/xds" // Register the xDS LB Registry Converters. "google.golang.org/grpc/xds/internal/balancer/wrrlocality" "google.golang.org/grpc/xds/internal/xdsclient/xdslbregistry" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/wrapperspb" v1xdsudpatypepb "github.com/cncf/xds/go/udpa/type/v1" @@ -48,7 +49,6 @@ import ( v3ringhashpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/ring_hash/v3" v3roundrobinpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/round_robin/v3" v3wrrlocalitypb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/wrr_locality/v3" - structpb "github.com/golang/protobuf/ptypes/struct" ) type s struct { diff --git a/xds/internal/xdsclient/xdsresource/filter_chain.go b/xds/internal/xdsclient/xdsresource/filter_chain.go index 2541fc8cd7bf..29b14e636bf2 100644 --- a/xds/internal/xdsclient/xdsresource/filter_chain.go +++ b/xds/internal/xdsclient/xdsresource/filter_chain.go @@ -23,11 +23,10 @@ import ( "net" "sync/atomic" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" "google.golang.org/grpc/internal/resolver" "google.golang.org/grpc/xds/internal/httpfilter" "google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version" + "google.golang.org/protobuf/proto" v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" @@ -630,7 +629,7 @@ func processNetworkFilters(filters []*v3listenerpb.Filter) (*FilterChain, error) return nil, fmt.Errorf("network filters {%+v} has unsupported network filter %q in filter {%+v}", filters, tc.GetTypeUrl(), filter) } hcm := &v3httppb.HttpConnectionManager{} - if err := ptypes.UnmarshalAny(tc, hcm); err != nil { + if err := tc.UnmarshalTo(hcm); err != nil { return nil, fmt.Errorf("network filters {%+v} failed unmarshaling of network filter {%+v}: %v", filters, filter, err) } // "Any filters after HttpConnectionManager should be ignored during diff --git a/xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go b/xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go index 0019162a0097..e373034e5635 100644 --- a/xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go +++ b/xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go @@ -48,9 +48,9 @@ import ( v3ringhashpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/ring_hash/v3" v3roundrobinpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/round_robin/v3" v3wrrlocalitypb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/wrr_locality/v3" - "github.com/golang/protobuf/proto" - anypb "github.com/golang/protobuf/ptypes/any" - structpb "github.com/golang/protobuf/ptypes/struct" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/structpb" ) type s struct { diff --git a/xds/internal/xdsclient/xdsresource/type.go b/xds/internal/xdsclient/xdsresource/type.go index 35cfa9ee7678..994204101835 100644 --- a/xds/internal/xdsclient/xdsresource/type.go +++ b/xds/internal/xdsclient/xdsresource/type.go @@ -21,8 +21,8 @@ import ( "time" v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" - "github.com/golang/protobuf/proto" "google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" ) diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_cds.go b/xds/internal/xdsclient/xdsresource/unmarshal_cds.go index ec58468631fb..c5b751d4d8a9 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_cds.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_cds.go @@ -30,7 +30,6 @@ import ( v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3aggregateclusterpb "github.com/envoyproxy/go-control-plane/envoy/extensions/clusters/aggregate/v3" v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" - "github.com/golang/protobuf/proto" "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/internal/pretty" @@ -38,6 +37,7 @@ import ( "google.golang.org/grpc/internal/xds/matcher" "google.golang.org/grpc/xds/internal/xdsclient/xdslbregistry" "google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" ) diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go b/xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go index 24035263b99a..638cf91980dc 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go @@ -39,7 +39,7 @@ import ( v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" v3matcherpb "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" - anypb "github.com/golang/protobuf/ptypes/any" + "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/wrapperspb" ) diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_eds.go b/xds/internal/xdsclient/xdsresource/unmarshal_eds.go index 95333aaf61d5..f65845b702c8 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_eds.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_eds.go @@ -26,9 +26,9 @@ import ( v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" - "github.com/golang/protobuf/proto" "google.golang.org/grpc/internal/pretty" "google.golang.org/grpc/xds/internal" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" ) diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_eds_test.go b/xds/internal/xdsclient/xdsresource/unmarshal_eds_test.go index a5c466dd4d74..f2419eac55a4 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_eds_test.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_eds_test.go @@ -27,13 +27,13 @@ import ( v3endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" - anypb "github.com/golang/protobuf/ptypes/any" - wrapperspb "github.com/golang/protobuf/ptypes/wrappers" "github.com/google/go-cmp/cmp" "google.golang.org/grpc/internal/pretty" "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/xds/internal" "google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version" + "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/wrapperspb" ) func (s) TestEDSParseRespProto(t *testing.T) { diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_lds.go b/xds/internal/xdsclient/xdsresource/unmarshal_lds.go index 8f18b02e28a6..67ad58d43701 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_lds.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_lds.go @@ -27,9 +27,8 @@ import ( v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" "google.golang.org/grpc/xds/internal/httpfilter" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" ) @@ -121,17 +120,17 @@ func processClientSideListener(lis *v3listenerpb.Listener) (*ListenerUpdate, err func unwrapHTTPFilterConfig(config *anypb.Any) (proto.Message, string, error) { switch { - case ptypes.Is(config, &v3xdsxdstypepb.TypedStruct{}): + case config.MessageIs(&v3xdsxdstypepb.TypedStruct{}): // The real type name is inside the new TypedStruct message. s := new(v3xdsxdstypepb.TypedStruct) - if err := ptypes.UnmarshalAny(config, s); err != nil { + if err := config.UnmarshalTo(s); err != nil { return nil, "", fmt.Errorf("error unmarshalling TypedStruct filter config: %v", err) } return s, s.GetTypeUrl(), nil - case ptypes.Is(config, &v1udpaudpatypepb.TypedStruct{}): + case config.MessageIs(&v1udpaudpatypepb.TypedStruct{}): // The real type name is inside the old TypedStruct message. s := new(v1udpaudpatypepb.TypedStruct) - if err := ptypes.UnmarshalAny(config, s); err != nil { + if err := config.UnmarshalTo(s); err != nil { return nil, "", fmt.Errorf("error unmarshalling TypedStruct filter config: %v", err) } return s, s.GetTypeUrl(), nil @@ -171,8 +170,8 @@ func processHTTPFilterOverrides(cfgs map[string]*anypb.Any) (map[string]httpfilt for name, cfg := range cfgs { optional := false s := new(v3routepb.FilterConfig) - if ptypes.Is(cfg, s) { - if err := ptypes.UnmarshalAny(cfg, s); err != nil { + if cfg.MessageIs(s) { + if err := cfg.UnmarshalTo(s); err != nil { return nil, fmt.Errorf("filter override %q: error unmarshalling FilterConfig: %v", name, err) } cfg = s.GetConfig() diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go b/xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go index 5b260444c11e..c6cd3a68352a 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go @@ -24,14 +24,17 @@ import ( "time" v2xdspb "github.com/envoyproxy/go-control-plane/envoy/api/v2" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "google.golang.org/grpc/internal/pretty" "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/internal/testutils/xds/e2e" "google.golang.org/grpc/xds/internal/httpfilter" "google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/wrapperspb" v1udpaudpatypepb "github.com/cncf/udpa/go/udpa/type/v1" v3xdsxdstypepb "github.com/cncf/xds/go/xds/type/v3" @@ -44,9 +47,6 @@ import ( v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" v3matcherpb "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" - anypb "github.com/golang/protobuf/ptypes/any" - spb "github.com/golang/protobuf/ptypes/struct" - wrapperspb "github.com/golang/protobuf/ptypes/wrappers" _ "google.golang.org/grpc/xds/internal/httpfilter/rbac" // Register the RBAC HTTP filter. _ "google.golang.org/grpc/xds/internal/httpfilter/router" // Register the router filter. @@ -1826,9 +1826,9 @@ var clientOnlyCustomFilterConfig = &anypb.Any{ // This custom filter uses the old TypedStruct message from the cncf/udpa repo. var customFilterOldTypedStructConfig = &v1udpaudpatypepb.TypedStruct{ TypeUrl: "custom.filter", - Value: &spb.Struct{ - Fields: map[string]*spb.Value{ - "foo": {Kind: &spb.Value_StringValue{StringValue: "bar"}}, + Value: &structpb.Struct{ + Fields: map[string]*structpb.Value{ + "foo": {Kind: &structpb.Value_StringValue{StringValue: "bar"}}, }, }, } @@ -1836,9 +1836,9 @@ var customFilterOldTypedStructConfig = &v1udpaudpatypepb.TypedStruct{ // This custom filter uses the new TypedStruct message from the cncf/xds repo. var customFilterNewTypedStructConfig = &v3xdsxdstypepb.TypedStruct{ TypeUrl: "custom.filter", - Value: &spb.Struct{ - Fields: map[string]*spb.Value{ - "foo": {Kind: &spb.Value_StringValue{StringValue: "bar"}}, + Value: &structpb.Struct{ + Fields: map[string]*structpb.Value{ + "foo": {Kind: &structpb.Value_StringValue{StringValue: "bar"}}, }, }, } diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_rds.go b/xds/internal/xdsclient/xdsresource/unmarshal_rds.go index 2e39540769b2..db862514eb58 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_rds.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_rds.go @@ -24,10 +24,10 @@ import ( "strings" "time" - "github.com/golang/protobuf/proto" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal/xds/matcher" "google.golang.org/grpc/xds/internal/clusterspecifier" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_rds_test.go b/xds/internal/xdsclient/xdsresource/unmarshal_rds_test.go index abe8bfc7dbc8..c545ba45e996 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_rds_test.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_rds_test.go @@ -26,7 +26,6 @@ import ( "time" v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" - "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/grpc/codes" @@ -36,7 +35,10 @@ import ( "google.golang.org/grpc/xds/internal/clusterspecifier" "google.golang.org/grpc/xds/internal/httpfilter" "google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/wrapperspb" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" rpb "github.com/envoyproxy/go-control-plane/envoy/config/rbac/v3" @@ -44,8 +46,6 @@ import ( v3rbacpb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/rbac/v3" v3matcherpb "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" - anypb "github.com/golang/protobuf/ptypes/any" - wrapperspb "github.com/golang/protobuf/ptypes/wrappers" ) func (s) TestRDSGenerateRDSUpdateFromRouteConfiguration(t *testing.T) {