From febcd0bbf28a407be312c4a162f2a629a8b22de1 Mon Sep 17 00:00:00 2001 From: Benji Rewis Date: Wed, 11 Dec 2024 14:18:19 -0500 Subject: [PATCH] update api dependency and lint --- app/data_client.go | 2 ++ app/data_client_test.go | 5 +++++ cli/client_test.go | 5 +++++ cli/data.go | 2 ++ components/movementsensor/replay/replay.go | 1 + .../replay/replay_utils_test.go | 7 ++++++- go.mod | 4 +--- go.sum | 2 ++ robot/impl/local_robot_test.go | 20 +++++++++---------- robot/robot.go | 1 + testutils/inject/data_service_client.go | 7 ++++++- 11 files changed, 41 insertions(+), 15 deletions(-) diff --git a/app/data_client.go b/app/data_client.go index f5798baa8a7..71dba118233 100644 --- a/app/data_client.go +++ b/app/data_client.go @@ -369,6 +369,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, @@ -1219,6 +1220,7 @@ func binaryMetadataFromProto(proto *pb.BinaryMetadata) BinaryMetadata { } } +//nolint:deprecated,staticcheck func tabularDataFromProto(proto *pb.TabularData, metadata *pb.CaptureMetadata) TabularData { return TabularData{ Data: proto.Data.AsMap(), diff --git a/app/data_client_test.go b/app/data_client_test.go index 2ee2d87a140..5b98706b963 100644 --- a/app/data_client_test.go +++ b/app/data_client_test.go @@ -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, @@ -695,6 +699,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, diff --git a/cli/client_test.go b/cli/client_test.go index 1f9035d44dd..2a5749e4300 100644 --- a/cli/client_test.go +++ b/cli/client_test.go @@ -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,staticcheck ) (*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 diff --git a/cli/data.go b/cli/data.go index 2158aa8a278..62df50d6224 100644 --- a/cli/data.go +++ b/cli/data.go @@ -612,6 +612,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 @@ -627,6 +628,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, diff --git a/components/movementsensor/replay/replay.go b/components/movementsensor/replay/replay.go index ef30cdc9fce..8656ad89a34 100644 --- a/components/movementsensor/replay/replay.go +++ b/components/movementsensor/replay/replay.go @@ -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, diff --git a/components/movementsensor/replay/replay_utils_test.go b/components/movementsensor/replay/replay_utils_test.go index 47265e919c6..70290eda0a9 100644 --- a/components/movementsensor/replay/replay_utils_test.go +++ b/components/movementsensor/replay/replay_utils_test.go @@ -43,12 +43,15 @@ 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, -) (*datapb.TabularDataByFilterResponse, error) { +) (*datapb.TabularDataByFilterResponse, error) { //nolint:deprecated,staticcheck filter := req.DataRequest.GetFilter() last := req.DataRequest.GetLast() limit := req.DataRequest.GetLimit() + //nolint:deprecated,staticcheck var dataset []*datapb.TabularData var dataIndex int var err error @@ -75,6 +78,7 @@ func (mDServer *mockDataServiceServer) TabularDataByFilter(ctx context.Context, last = fmt.Sprint(dataIndex) + //nolint:deprecated,staticcheck tabularData := &datapb.TabularData{ Data: data, TimeRequested: timeReq, @@ -84,6 +88,7 @@ func (mDServer *mockDataServiceServer) TabularDataByFilter(ctx context.Context, } // Construct response + //nolint:deprecated,staticcheck resp := &datapb.TabularDataByFilterResponse{ Data: dataset, Last: last, diff --git a/go.mod b/go.mod index 48d938d9416..ab6fba4f145 100644 --- a/go.mod +++ b/go.mod @@ -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.371 go.viam.com/test v1.2.4 go.viam.com/utils v0.1.116 goji.io v2.0.2+incompatible @@ -431,5 +431,3 @@ require ( github.com/ziutek/mymysql v1.5.4 // indirect golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e ) - -replace go.viam.com/api => ./api diff --git a/go.sum b/go.sum index 3bb10767c36..0e2c1990183 100644 --- a/go.sum +++ b/go.sum @@ -1512,6 +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.371 h1:RkiCPubgWFFKa/gdYBsAtzqQwKBd1d68Us/yp1wPGds= +go.viam.com/api v0.1.371/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= diff --git a/robot/impl/local_robot_test.go b/robot/impl/local_robot_test.go index 759e9e863a6..3da2de7199c 100644 --- a/robot/impl/local_robot_test.go +++ b/robot/impl/local_robot_test.go @@ -4445,15 +4445,15 @@ func TestRemovingOfflineRemotes(t *testing.T) { } // Tests that machine state properly reports initializing and running. -//func TestMachineState(t *testing.T) { + //logger := logging.NewTestLogger(t) //ctx := context.Background() -//completeComponentConstruction := make(chan struct{}, 1) +// completeComponentConstruction := make(chan struct{}, 1) //// Register a `foo` component whose construction completion can be delayed, //// and defer its deregistration. -//resource.RegisterComponent(generic.API, fooModel, resource.Registration[resource.Resource, +// resource.RegisterComponent(generic.API, fooModel, resource.Registration[resource.Resource, //resource.NoNativeConfig]{ //Constructor: func( //ctx context.Context, @@ -4464,7 +4464,7 @@ func TestRemovingOfflineRemotes(t *testing.T) { //// Delay completion of constructor until `completeComponentConstruction` is closed. //<-completeComponentConstruction -//return &fooComponent{ +// return &fooComponent{ //Named: conf.ResourceName().AsNamed(), //logger: logger, //}, nil @@ -4474,7 +4474,7 @@ func TestRemovingOfflineRemotes(t *testing.T) { //resource.Deregister(generic.API, fooModel) //}() -//cfg := &config.Config{ +// cfg := &config.Config{ //Components: []resource.Config{ //{ //Name: "foo", @@ -4486,28 +4486,28 @@ func TestRemovingOfflineRemotes(t *testing.T) { //r := setupLocalRobot(t, ctx, cfg, logger) //// Assert that robot reports a state of "initializing" until `foo` completes construction. -//machineStatus, err := r.MachineStatus(ctx) +// machineStatus, err := r.MachineStatus(ctx) //test.That(t, err, test.ShouldBeNil) //test.That(t, machineStatus, test.ShouldNotBeNil) //test.That(t, machineStatus.State, test.ShouldEqual, robot.StateInitializing) -//close(completeComponentConstruction) +// close(completeComponentConstruction) //// Assert that robot reports a state of "running" after `foo` completes //// construction. -//machineStatus, err = r.MachineStatus(ctx) +// machineStatus, err = r.MachineStatus(ctx) //test.That(t, err, test.ShouldBeNil) //test.That(t, machineStatus, test.ShouldNotBeNil) //test.That(t, machineStatus.State, test.ShouldEqual, robot.StateRunning) //// Reconfigure robot to replace `foo` with idential `bar` component (should build //// immediately, as `completeComponentConstruction` has already been closed.) -//cfg.Components[0].Name = "bar" +// cfg.Components[0].Name = "bar" //r.Reconfigure(ctx, cfg) //// Assert that robot continues to report a state of "running" even after further //// reconfiguration. -//machineStatus, err = r.MachineStatus(ctx) +// machineStatus, err = r.MachineStatus(ctx) //test.That(t, err, test.ShouldBeNil) //test.That(t, machineStatus, test.ShouldNotBeNil) //test.That(t, machineStatus.State, test.ShouldEqual, robot.StateRunning) diff --git a/robot/robot.go b/robot/robot.go index 206018f34b4..f5c55a941bc 100644 --- a/robot/robot.go +++ b/robot/robot.go @@ -330,6 +330,7 @@ func (rmr *RestartModuleRequest) MatchesModule(mod config.Module) bool { return mod.Name == rmr.ModuleName } +// MachineState captures the state of a machine. type MachineState uint8 const ( diff --git a/testutils/inject/data_service_client.go b/testutils/inject/data_service_client.go index c5ed8fe0148..731bcc94a8c 100644 --- a/testutils/inject/data_service_client.go +++ b/testutils/inject/data_service_client.go @@ -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) @@ -57,10 +59,13 @@ 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, -) (*datapb.TabularDataByFilterResponse, error) { +) (*datapb.TabularDataByFilterResponse, error) { //nolint:deprecated,staticcheck if client.TabularDataByFilterFunc == nil { + //nolint:deprecated,staticcheck return client.DataServiceClient.TabularDataByFilter(ctx, in, opts...) } return client.TabularDataByFilterFunc(ctx, in, opts...)