Skip to content

Commit

Permalink
Add nolints for tabularDataByFilter in RDK (viamrobotics#4619)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayvuyyuru authored Dec 12, 2024
1 parent 5720618 commit 567b1ab
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/billing_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func (c *BillingClient) SendPaymentRequiredEmail(ctx context.Context, customerOr
}

func usageCostTypeFromProto(costType pb.UsageCostType) UsageCostType {
//nolint:exhaustive
switch costType {
case pb.UsageCostType_USAGE_COST_TYPE_UNSPECIFIED:
return UsageCostTypeUnspecified
Expand Down
3 changes: 3 additions & 0 deletions app/data_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ func BsonToGo(rawData [][]byte) ([]map[string]interface{}, error) {
}

// TabularDataByFilter queries tabular data and metadata based on given filters.
// Deprecated: This endpoint will be removed in a future version.
func (d *DataClient) TabularDataByFilter(ctx context.Context, opts *DataByFilterOptions) (*TabularDataByFilterResponse, error) {
dataReq := pb.DataRequest{}
var countOnly, includeInternalData bool
Expand All @@ -369,6 +370,7 @@ func (d *DataClient) TabularDataByFilter(ctx context.Context, opts *DataByFilter
countOnly = opts.CountOnly
includeInternalData = opts.IncludeInternalData
}
//nolint:deprecated,staticcheck
resp, err := d.dataClient.TabularDataByFilter(ctx, &pb.TabularDataByFilterRequest{
DataRequest: &dataReq,
CountOnly: countOnly,
Expand Down Expand Up @@ -1266,6 +1268,7 @@ func binaryMetadataFromProto(proto *pb.BinaryMetadata) (*BinaryMetadata, error)
}, nil
}

//nolint:deprecated,staticcheck
func tabularDataFromProto(proto *pb.TabularData, metadata *pb.CaptureMetadata) (*TabularData, error) {
if proto == nil {
return nil, nil
Expand Down
5 changes: 5 additions & 0 deletions app/data_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,23 @@ func TestDataClient(t *testing.T) {

t.Run("TabularDataByFilter", func(t *testing.T) {
dataStruct, _ := utils.StructToStructPb(data)
//nolint:deprecated,staticcheck
tabularDataPb := &pb.TabularData{
Data: dataStruct,
MetadataIndex: 0,
TimeRequested: timestamppb.New(start),
TimeReceived: timestamppb.New(end),
}
//nolint:deprecated,staticcheck
grpcClient.TabularDataByFilterFunc = func(ctx context.Context, in *pb.TabularDataByFilterRequest,
opts ...grpc.CallOption,
) (*pb.TabularDataByFilterResponse, error) {
test.That(t, in.DataRequest, test.ShouldResemble, dataRequestToProto(dataRequest))
test.That(t, in.CountOnly, test.ShouldBeTrue)
test.That(t, in.IncludeInternalData, test.ShouldBeTrue)
//nolint:deprecated,staticcheck
return &pb.TabularDataByFilterResponse{
//nolint:deprecated,staticcheck
Data: []*pb.TabularData{tabularDataPb},
Count: pbCount,
Last: last,
Expand Down Expand Up @@ -722,6 +726,7 @@ func TestDataSyncClient(t *testing.T) {
t.Run("TabularDataCaptureUpload", func(t *testing.T) {
uploadMetadata.Type = DataTypeTabularSensor
dataStruct, _ := utils.StructToStructPb(data)
//nolint:deprecated,staticcheck
tabularDataPb := &pb.TabularData{
Data: dataStruct,
MetadataIndex: 0,
Expand Down
5 changes: 5 additions & 0 deletions cli/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,18 @@ func TestTabularDataByFilterAction(t *testing.T) {
// so we need a way of telling our injected method when data has already been sent so we
// can send an empty response
var dataRequested bool
//nolint:deprecated,staticcheck
tabularDataByFilterFunc := func(ctx context.Context, in *datapb.TabularDataByFilterRequest, opts ...grpc.CallOption,
//nolint:deprecated
) (*datapb.TabularDataByFilterResponse, error) {
if dataRequested {
//nolint:deprecated,staticcheck
return &datapb.TabularDataByFilterResponse{}, nil
}
dataRequested = true
//nolint:deprecated,staticcheck
return &datapb.TabularDataByFilterResponse{
//nolint:deprecated,staticcheck
Data: []*datapb.TabularData{{Data: pbStruct}},
Metadata: []*datapb.CaptureMetadata{{LocationId: "loc-id"}},
}, nil
Expand Down
2 changes: 2 additions & 0 deletions cli/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
}

var err error
//nolint:deprecated,staticcheck
var resp *datapb.TabularDataByFilterResponse
// TODO(DATA-640): Support export in additional formats.
//nolint:gosec
Expand All @@ -662,6 +663,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
mdIndex := 0
for {
for count := 0; count < maxRetryCount; count++ {
//nolint:deprecated,staticcheck
resp, err = c.dataClient.TabularDataByFilter(context.Background(), &datapb.TabularDataByFilterRequest{
DataRequest: &datapb.DataRequest{
Filter: filter,
Expand Down
1 change: 1 addition & 0 deletions components/movementsensor/replay/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ func (replay *replayMovementSensor) updateCache(ctx context.Context, method meth
filter.Method = string(method)

// Retrieve data from the cloud
//nolint:deprecated,staticcheck
resp, err := replay.dataClient.TabularDataByFilter(ctx, &datapb.TabularDataByFilterRequest{
DataRequest: &datapb.DataRequest{
Filter: filter,
Expand Down
5 changes: 5 additions & 0 deletions components/movementsensor/replay/replay_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ type mockDataServiceServer struct {

// TabularDataByFilter is a mocked version of the Data Service function of a similar name. It returns a response with
// data corresponding to the stored data associated with that function and index.
//
//nolint:deprecated,staticcheck
func (mDServer *mockDataServiceServer) TabularDataByFilter(ctx context.Context, req *datapb.TabularDataByFilterRequest,

//nolint:deprecated,staticcheck
) (*datapb.TabularDataByFilterResponse, error) {
filter := req.DataRequest.GetFilter()
last := req.DataRequest.GetLast()
Expand Down Expand Up @@ -84,6 +88,7 @@ func (mDServer *mockDataServiceServer) TabularDataByFilter(ctx context.Context,
}

// Construct response
//nolint:deprecated,staticcheck
resp := &datapb.TabularDataByFilterResponse{
Data: dataset,
Last: last,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
go.uber.org/atomic v1.11.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
go.viam.com/api v0.1.366
go.viam.com/api v0.1.372
go.viam.com/test v1.2.4
go.viam.com/utils v0.1.116
goji.io v2.0.2+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,8 @@ go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.viam.com/api v0.1.366 h1:lUen0W04hwdFL95GoQkYaweZO5ySG40BnUl7HHVZE3o=
go.viam.com/api v0.1.366/go.mod h1:g5eipXHNm0rQmW7DWya6avKcmzoypLmxnMlAaIsE5Ls=
go.viam.com/api v0.1.372 h1:Al9P7yojBDdNVAF7nrr5BAbzCvb+vrSp8N7BitbV0mQ=
go.viam.com/api v0.1.372/go.mod h1:g5eipXHNm0rQmW7DWya6avKcmzoypLmxnMlAaIsE5Ls=
go.viam.com/test v1.2.4 h1:JYgZhsuGAQ8sL9jWkziAXN9VJJiKbjoi9BsO33TW3ug=
go.viam.com/test v1.2.4/go.mod h1:zI2xzosHdqXAJ/kFqcN+OIF78kQuTV2nIhGZ8EzvaJI=
go.viam.com/utils v0.1.116 h1:hoCj3SsV8LZAOEP75TjMeX57axhravS8rNUYmhpTWtM=
Expand Down
6 changes: 6 additions & 0 deletions testutils/inject/data_service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// DataServiceClient represents a fake instance of a data service client.
type DataServiceClient struct {
datapb.DataServiceClient
//nolint:deprecated,staticcheck
TabularDataByFilterFunc func(ctx context.Context, in *datapb.TabularDataByFilterRequest,
//nolint:deprecated,staticcheck
opts ...grpc.CallOption) (*datapb.TabularDataByFilterResponse, error)
TabularDataBySQLFunc func(ctx context.Context, in *datapb.TabularDataBySQLRequest,
opts ...grpc.CallOption) (*datapb.TabularDataBySQLResponse, error)
Expand Down Expand Up @@ -57,10 +59,14 @@ type DataServiceClient struct {
}

// TabularDataByFilter calls the injected TabularDataByFilter or the real version.
//
//nolint:deprecated,staticcheck
func (client *DataServiceClient) TabularDataByFilter(ctx context.Context, in *datapb.TabularDataByFilterRequest,
opts ...grpc.CallOption,
//nolint:deprecated,staticcheck
) (*datapb.TabularDataByFilterResponse, error) {
if client.TabularDataByFilterFunc == nil {
//nolint:deprecated,staticcheck
return client.DataServiceClient.TabularDataByFilter(ctx, in, opts...)
}
return client.TabularDataByFilterFunc(ctx, in, opts...)
Expand Down

0 comments on commit 567b1ab

Please sign in to comment.