Skip to content

Commit

Permalink
b/161168963: Add StatsConfig and StatsSink to Resolver (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
toddbeckman-g authored Jul 17, 2020
1 parent 5131ffb commit 265a441
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/go/util/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
20 changes: 8 additions & 12 deletions src/go/util/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand Down

0 comments on commit 265a441

Please sign in to comment.