From 265a4412d5109e68162b05235fa1c62e811b30a0 Mon Sep 17 00:00:00 2001 From: Todd Beckman <59070329+toddbeckman-g@users.noreply.github.com> Date: Fri, 17 Jul 2020 11:12:25 -0600 Subject: [PATCH] b/161168963: Add StatsConfig and StatsSink to Resolver (#230) --- src/go/util/marshal.go | 7 +++++++ src/go/util/marshal_test.go | 20 ++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/go/util/marshal.go b/src/go/util/marshal.go index 07e7743dd..c9a524c51 100644 --- a/src/go/util/marshal.go +++ b/src/go/util/marshal.go @@ -26,6 +26,7 @@ import ( pmpb "github.com/GoogleCloudPlatform/esp-v2/src/go/proto/api/envoy/v7/http/path_matcher" scpb "github.com/GoogleCloudPlatform/esp-v2/src/go/proto/api/envoy/v7/http/service_control" + statspb "github.com/envoyproxy/go-control-plane/envoy/config/metrics/v3" accessfilepb "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/file/v3" accessgrpcpb "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/grpc/v3" transcoderpb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_json_transcoder/v3" @@ -103,6 +104,12 @@ var Resolver = FuncResolver(func(url string) (proto.Message, error) { return new(accessgrpcpb.TcpGrpcAccessLogConfig), nil case "type.googleapis.com/envoy.extensions.access_loggers.grpc.v3.CommonGrpcAccessLogConfig": return new(accessgrpcpb.CommonGrpcAccessLogConfig), nil + case "type.googleapis.com/envoy.config.metrics.v3.StatsConfig": + return new(statspb.StatsConfig), nil + case "type.googleapis.com/envoy.config.metrics.v3.StatsSink": + return new(statspb.StatsSink), nil + case "type.googleapis.com/envoy.config.metrics.v3.StatsdSink": + return new(statspb.StatsdSink), nil default: return nil, fmt.Errorf("unexpected protobuf.Any with url: %s", url) } diff --git a/src/go/util/marshal_test.go b/src/go/util/marshal_test.go index a13423884..cc5be7dd3 100644 --- a/src/go/util/marshal_test.go +++ b/src/go/util/marshal_test.go @@ -23,6 +23,7 @@ import ( "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" + statspb "github.com/envoyproxy/go-control-plane/envoy/config/metrics/v3" accessfilepb "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/file/v3" accessgrpcpb "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/grpc/v3" confpb "google.golang.org/genproto/googleapis/api/serviceconfig" @@ -34,18 +35,13 @@ func TestResolver(t *testing.T) { tests := []struct { msg proto.Message }{ - { - msg: &accessfilepb.FileAccessLog{}, - }, - { - msg: &accessgrpcpb.HttpGrpcAccessLogConfig{}, - }, - { - msg: &accessgrpcpb.TcpGrpcAccessLogConfig{}, - }, - { - msg: &accessgrpcpb.CommonGrpcAccessLogConfig{}, - }, + {msg: &accessfilepb.FileAccessLog{}}, + {msg: &accessgrpcpb.HttpGrpcAccessLogConfig{}}, + {msg: &accessgrpcpb.TcpGrpcAccessLogConfig{}}, + {msg: &accessgrpcpb.CommonGrpcAccessLogConfig{}}, + {msg: &statspb.StatsSink{}}, + {msg: &statspb.StatsdSink{}}, + {msg: &statspb.StatsConfig{}}, } marshaler := &jsonpb.Marshaler{