Skip to content

Commit

Permalink
[7.17](backport #37212) Replace EOL modules: github.com/golang/protob…
Browse files Browse the repository at this point in the history
…uf by google.golang.org/protobuf (#37469)

* Replace EOL modules: github.com/golang/protobuf by google.golang.org/protobuf (#37212)

(cherry picked from commit b59a8f4)
---------

Co-authored-by: Anderson Queiroz <[email protected]>
  • Loading branch information
mergify[bot] and AndersonQ authored Jan 5, 2024
1 parent 7aedd72 commit 38ba816
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 38 deletions.
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29306,11 +29306,11 @@ Contents of probable licence file $GOMODCACHE/github.com/google/[email protected]/LI

--------------------------------------------------------------------------------
Dependency : github.com/google/licenseclassifier
Version: v0.0.0-20200402202327-879cb1424de0
Version: v0.0.0-20221004142553-c1ed8fcf4bab
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/google/[email protected]20200402202327-879cb1424de0/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/google/[email protected]20221004142553-c1ed8fcf4bab/LICENSE:


Apache License
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ require (
github.com/gofrs/uuid v4.4.0+incompatible
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3
github.com/golang/snappy v0.0.4
github.com/gomodule/redigo v1.8.3
github.com/google/flatbuffers v23.3.3+incompatible
Expand Down Expand Up @@ -199,6 +198,7 @@ require (
require (
github.com/elastic/elastic-agent-libs v0.6.2
github.com/elastic/elastic-agent-system-metrics v0.4.4
github.com/golang/protobuf v1.5.3
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98
)

Expand Down Expand Up @@ -242,7 +242,7 @@ require (
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/licenseclassifier v0.0.0-20200402202327-879cb1424de0 // indirect
github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
Expand Down
4 changes: 3 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,10 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/licenseclassifier v0.0.0-20200402202327-879cb1424de0 h1:OggOMmdI0JLwg1FkOKH9S7fVHF0oEm8PX6S8kAdpOps=
github.com/google/licenseclassifier v0.0.0-20200402202327-879cb1424de0/go.mod h1:qsqn2hxC+vURpyBRygGUuinTO42MFRLcsmQ/P8v94+M=
github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab h1:okY7fFoWybMbxiHkaqStN4mxSrPfYmTZl5Zh32Z5FjY=
github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab/go.mod h1:jkYIPv59uiw+1MxTWlqQEKebsUDV1DCXQtBBn5lVzf4=
github.com/google/licenseclassifier/v2 v2.0.0-alpha.1/go.mod h1:YAgBGGTeNDMU+WfIgaFvjZe4rudym4f6nIn8ZH5X+VM=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw=
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/httpjson/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func TestStatelessHTTPJSONInput(t *testing.T) {
var g errgroup.Group
g.Go(func() error { return input.Run(ctx, chanClient) })

timeout := time.NewTimer(5 * time.Second)
timeout := time.NewTimer(10 * time.Second)
t.Cleanup(func() { _ = timeout.Stop() })

var receivedCount int
Expand Down
7 changes: 4 additions & 3 deletions x-pack/functionbeat/provider/aws/aws/kinesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
"github.com/aws/aws-lambda-go/events"
"github.com/awslabs/kinesis-aggregation/go/deaggregator"
aggRecProto "github.com/awslabs/kinesis-aggregation/go/records"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/runtime/protoimpl"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/x-pack/functionbeat/function/provider"
Expand Down Expand Up @@ -133,14 +134,14 @@ func generateAggregatedKinesisEvent(validRec bool) events.KinesisEvent {
partKeyTable = append(partKeyTable, "0")

aggRec.PartitionKeyTable = partKeyTable
data, _ := proto.Marshal(aggRec)
data, _ := proto.Marshal(protoimpl.X.ProtoMessageV2Of(aggRec))
md5Hash := md5.Sum(data)
aggRecBytes = append(aggRecBytes, data...)
aggRecBytes = append(aggRecBytes, md5Hash[:]...)

return events.KinesisEvent{
Records: []events.KinesisEventRecord{
events.KinesisEventRecord{
{
AwsRegion: "east-1",
EventID: "1234",
EventName: "connect",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import (
"testing"
"time"

"google.golang.org/protobuf/runtime/protoimpl"

"github.com/aws/aws-lambda-go/events"
"github.com/awslabs/kinesis-aggregation/go/deaggregator"
aggRecProto "github.com/awslabs/kinesis-aggregation/go/records"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/proto"

"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
Expand All @@ -31,7 +33,7 @@ func TestCloudwatch(t *testing.T) {
SubscriptionFilters: []string{"MyFilter"},
MessageType: "DATA_MESSAGE",
LogEvents: []events.CloudwatchLogsLogEvent{
events.CloudwatchLogsLogEvent{
{
ID: "1234567890123456789",
Timestamp: 1566908691193,
Message: "my interesting message",
Expand Down Expand Up @@ -391,7 +393,7 @@ func generateKinesisAggregateRecord(numRecords int, valid bool) []byte {
}

aggRec.PartitionKeyTable = partKeyTable
data, _ := proto.Marshal(aggRec)
data, _ := proto.Marshal(protoimpl.X.ProtoMessageV2Of(aggRec))
md5Hash := md5.Sum(data)
aggRecBytes = append(aggRecBytes, data...)
aggRecBytes = append(aggRecBytes, md5Hash[:]...)
Expand Down
12 changes: 6 additions & 6 deletions x-pack/metricbeat/module/gcp/metrics/compute/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ package compute
import (
"testing"

"github.com/golang/protobuf/ptypes/timestamp"
monitoring "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb"
"github.com/stretchr/testify/assert"
"google.golang.org/genproto/googleapis/api/metric"
"google.golang.org/genproto/googleapis/api/monitoredres"
monitoring "google.golang.org/genproto/googleapis/monitoring/v3"
"google.golang.org/protobuf/types/known/timestamppb"
)

var fake = &monitoring.TimeSeries{
Expand Down Expand Up @@ -41,10 +41,10 @@ var fake = &monitoring.TimeSeries{
Value: &monitoring.TypedValue_DoubleValue{DoubleValue: 0.0041224284852319215},
},
Interval: &monitoring.TimeInterval{
StartTime: &timestamp.Timestamp{
StartTime: &timestamppb.Timestamp{
Seconds: 1569932700,
},
EndTime: &timestamp.Timestamp{
EndTime: &timestamppb.Timestamp{
Seconds: 1569932700,
},
},
Expand All @@ -53,10 +53,10 @@ var fake = &monitoring.TimeSeries{
Value: &monitoring.TypedValue_DoubleValue{DoubleValue: 0.004205757571772513},
},
Interval: &monitoring.TimeInterval{
StartTime: &timestamp.Timestamp{
StartTime: &timestamppb.Timestamp{
Seconds: 1569932640,
},
EndTime: &timestamp.Timestamp{
EndTime: &timestamppb.Timestamp{
Seconds: 1569932640,
},
},
Expand Down
15 changes: 7 additions & 8 deletions x-pack/metricbeat/module/gcp/metrics/metrics_requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import (
"sync"
"time"

"github.com/golang/protobuf/ptypes/duration"

monitoring "cloud.google.com/go/monitoring/apiv3"
"github.com/golang/protobuf/ptypes/timestamp"
monitoring "cloud.google.com/go/monitoring/apiv3/v2"
"cloud.google.com/go/monitoring/apiv3/v2/monitoringpb"
"google.golang.org/api/iterator"
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/x-pack/metricbeat/module/gcp"
Expand Down Expand Up @@ -156,7 +155,7 @@ func (r *metricsRequester) getFilterForMetric(serviceName, m string) (f string)
}

// Returns a GCP TimeInterval based on the ingestDelay and samplePeriod from ListMetricDescriptor
func getTimeIntervalAligner(ingestDelay time.Duration, samplePeriod time.Duration, collectionPeriod *duration.Duration, inputAligner string) (*monitoringpb.TimeInterval, string) {
func getTimeIntervalAligner(ingestDelay time.Duration, samplePeriod time.Duration, collectionPeriod *durationpb.Duration, inputAligner string) (*monitoringpb.TimeInterval, string) {
var startTime, endTime, currentTime time.Time
var needsAggregation bool
currentTime = time.Now().UTC()
Expand All @@ -180,10 +179,10 @@ func getTimeIntervalAligner(ingestDelay time.Duration, samplePeriod time.Duratio
}

interval := &monitoringpb.TimeInterval{
StartTime: &timestamp.Timestamp{
StartTime: &timestamppb.Timestamp{
Seconds: startTime.Unix(),
},
EndTime: &timestamp.Timestamp{
EndTime: &timestamppb.Timestamp{
Seconds: endTime.Unix(),
},
}
Expand Down
12 changes: 6 additions & 6 deletions x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
"time"

"github.com/golang/protobuf/ptypes/duration"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/types/known/durationpb"

"github.com/elastic/beats/v7/libbeat/logp"
)
Expand Down Expand Up @@ -122,15 +122,15 @@ func TestGetTimeIntervalAligner(t *testing.T) {
title string
ingestDelay time.Duration
samplePeriod time.Duration
collectionPeriod *duration.Duration
collectionPeriod *durationpb.Duration
inputAligner string
expectedAligner string
}{
{
"test collectionPeriod equals to samplePeriod",
time.Duration(240) * time.Second,
time.Duration(60) * time.Second,
&duration.Duration{
&durationpb.Duration{
Seconds: int64(60),
},
"",
Expand All @@ -140,7 +140,7 @@ func TestGetTimeIntervalAligner(t *testing.T) {
"test collectionPeriod larger than samplePeriod",
time.Duration(240) * time.Second,
time.Duration(60) * time.Second,
&duration.Duration{
&durationpb.Duration{
Seconds: int64(300),
},
"ALIGN_MEAN",
Expand All @@ -150,7 +150,7 @@ func TestGetTimeIntervalAligner(t *testing.T) {
"test collectionPeriod smaller than samplePeriod",
time.Duration(240) * time.Second,
time.Duration(60) * time.Second,
&duration.Duration{
&durationpb.Duration{
Seconds: int64(30),
},
"ALIGN_MAX",
Expand All @@ -160,7 +160,7 @@ func TestGetTimeIntervalAligner(t *testing.T) {
"test collectionPeriod equals to samplePeriod with given aligner",
time.Duration(240) * time.Second,
time.Duration(60) * time.Second,
&duration.Duration{
&durationpb.Duration{
Seconds: int64(60),
},
"ALIGN_MEAN",
Expand Down
12 changes: 6 additions & 6 deletions x-pack/metricbeat/module/gcp/metrics/metricset.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"strings"
"time"

monitoring "cloud.google.com/go/monitoring/apiv3"
"github.com/golang/protobuf/ptypes/duration"
monitoring "cloud.google.com/go/monitoring/apiv3/v2"
"cloud.google.com/go/monitoring/apiv3/v2/monitoringpb"
"github.com/pkg/errors"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/genproto/googleapis/api/metric"
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
"google.golang.org/protobuf/types/known/durationpb"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
Expand Down Expand Up @@ -106,7 +106,7 @@ type config struct {
CredentialsFilePath string `config:"credentials_file_path"`

opt []option.ClientOption
period *duration.Duration
period *durationpb.Duration
}

// New creates a new instance of the MetricSet. New is responsible for unpacking
Expand All @@ -130,7 +130,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

m.MetricsConfig = metricsConfigs.Metrics
m.config.opt = []option.ClientOption{option.WithCredentialsFile(m.config.CredentialsFilePath)}
m.config.period = &duration.Duration{
m.config.period = &durationpb.Duration{
Seconds: int64(m.Module().Config().Period.Seconds()),
}

Expand Down Expand Up @@ -212,7 +212,7 @@ func (m *MetricSet) eventMapping(ctx context.Context, tss []timeSeriesWithAligne
return nil, errors.Wrap(err, "error trying to group time series data")
}

//Create single events for each group of data that matches some common patterns like labels and timestamp
// Create single events for each group of data that matches some common patterns like labels and timestamp
events := make([]mb.Event, 0)
for _, groupedEvents := range tsGrouped {
event := mb.Event{
Expand Down

0 comments on commit 38ba816

Please sign in to comment.