Switch to using google.golang.org/protobuf rather than github.com/golang/protobuf

This commit is contained in:
Matthew Brooks
2023-04-16 14:54:48 -06:00
parent e1fb06574f
commit 8a11d50738
3 changed files with 10 additions and 22 deletions

4
go.mod
View File

@@ -7,7 +7,6 @@ require (
github.com/evanphx/json-patch v4.12.0+incompatible github.com/evanphx/json-patch v4.12.0+incompatible
github.com/fsnotify/fsnotify v1.6.0 github.com/fsnotify/fsnotify v1.6.0
github.com/golang/mock v1.6.0 github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3
github.com/google/gofuzz v1.2.0 github.com/google/gofuzz v1.2.0
github.com/kubernetes-csi/csi-lib-utils v0.12.0 github.com/kubernetes-csi/csi-lib-utils v0.12.0
github.com/kubernetes-csi/csi-test/v4 v4.0.2 github.com/kubernetes-csi/csi-test/v4 v4.0.2
@@ -17,6 +16,7 @@ require (
github.com/prometheus/common v0.37.0 github.com/prometheus/common v0.37.0
github.com/spf13/cobra v1.6.1 github.com/spf13/cobra v1.6.1
google.golang.org/grpc v1.51.0 google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.1
k8s.io/api v0.27.0 k8s.io/api v0.27.0
k8s.io/apimachinery v0.27.0 k8s.io/apimachinery v0.27.0
k8s.io/client-go v0.27.0 k8s.io/client-go v0.27.0
@@ -38,6 +38,7 @@ require (
github.com/go-openapi/swag v0.22.3 // indirect github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect github.com/google/uuid v1.3.0 // indirect
@@ -61,7 +62,6 @@ require (
golang.org/x/time v0.1.0 // indirect golang.org/x/time v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect

View File

@@ -22,7 +22,6 @@ import (
"time" "time"
"github.com/container-storage-interface/spec/lib/go/csi" "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/protobuf/ptypes"
csirpc "github.com/kubernetes-csi/csi-lib-utils/rpc" csirpc "github.com/kubernetes-csi/csi-lib-utils/rpc"
"google.golang.org/grpc" "google.golang.org/grpc"
@@ -74,10 +73,8 @@ func (s *snapshot) CreateSnapshot(ctx context.Context, snapshotName string, volu
} }
klog.V(5).Infof("CSI CreateSnapshot: %s driver name [%s] snapshot ID [%s] time stamp [%v] size [%d] readyToUse [%v]", snapshotName, driverName, rsp.Snapshot.SnapshotId, rsp.Snapshot.CreationTime, rsp.Snapshot.SizeBytes, rsp.Snapshot.ReadyToUse) klog.V(5).Infof("CSI CreateSnapshot: %s driver name [%s] snapshot ID [%s] time stamp [%v] size [%d] readyToUse [%v]", snapshotName, driverName, rsp.Snapshot.SnapshotId, rsp.Snapshot.CreationTime, rsp.Snapshot.SizeBytes, rsp.Snapshot.ReadyToUse)
creationTime, err := ptypes.Timestamp(rsp.Snapshot.CreationTime)
if err != nil { creationTime := rsp.Snapshot.CreationTime.AsTime()
return "", "", time.Time{}, 0, false, err
}
return driverName, rsp.Snapshot.SnapshotId, creationTime, rsp.Snapshot.SizeBytes, rsp.Snapshot.ReadyToUse, nil return driverName, rsp.Snapshot.SnapshotId, creationTime, rsp.Snapshot.SizeBytes, rsp.Snapshot.ReadyToUse, nil
} }
@@ -138,9 +135,6 @@ func (s *snapshot) GetSnapshotStatus(ctx context.Context, snapshotID string, sna
return false, time.Time{}, 0, fmt.Errorf("can not find snapshot for snapshotID %s", snapshotID) return false, time.Time{}, 0, fmt.Errorf("can not find snapshot for snapshotID %s", snapshotID)
} }
creationTime, err := ptypes.Timestamp(rsp.Entries[0].Snapshot.CreationTime) creationTime := rsp.Entries[0].Snapshot.CreationTime.AsTime()
if err != nil {
return false, time.Time{}, 0, err
}
return rsp.Entries[0].Snapshot.ReadyToUse, creationTime, rsp.Entries[0].Snapshot.SizeBytes, nil return rsp.Entries[0].Snapshot.ReadyToUse, creationTime, rsp.Entries[0].Snapshot.SizeBytes, nil
} }

View File

@@ -25,7 +25,6 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi" "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"github.com/golang/protobuf/ptypes"
"github.com/kubernetes-csi/csi-lib-utils/connection" "github.com/kubernetes-csi/csi-lib-utils/connection"
"github.com/kubernetes-csi/csi-lib-utils/metrics" "github.com/kubernetes-csi/csi-lib-utils/metrics"
"github.com/kubernetes-csi/csi-test/v4/driver" "github.com/kubernetes-csi/csi-test/v4/driver"
@@ -33,6 +32,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -68,11 +68,8 @@ func createMockServer(t *testing.T) (*gomock.Controller, *driver.MockCSIDriver,
func TestCreateSnapshot(t *testing.T) { func TestCreateSnapshot(t *testing.T) {
defaultName := "snapshot-test" defaultName := "snapshot-test"
defaultID := "testid" defaultID := "testid"
createTimestamp := ptypes.TimestampNow() createTimestamp := timestamppb.Now()
createTime, err := ptypes.Timestamp(createTimestamp) createTime := createTimestamp.AsTime()
if err != nil {
t.Fatalf("Failed to convert timestamp to time: %v", err)
}
createSecrets := map[string]string{"foo": "bar"} createSecrets := map[string]string{"foo": "bar"}
defaultParameter := map[string]string{ defaultParameter := map[string]string{
@@ -338,11 +335,8 @@ func TestDeleteSnapshot(t *testing.T) {
func TestGetSnapshotStatus(t *testing.T) { func TestGetSnapshotStatus(t *testing.T) {
defaultID := "testid" defaultID := "testid"
size := int64(1000) size := int64(1000)
createTimestamp := ptypes.TimestampNow() createTimestamp := timestamppb.Now()
createTime, err := ptypes.Timestamp(createTimestamp) createTime := createTimestamp.AsTime()
if err != nil {
t.Fatalf("Failed to convert timestamp to time: %v", err)
}
defaultRequest := &csi.ListSnapshotsRequest{ defaultRequest := &csi.ListSnapshotsRequest{
SnapshotId: defaultID, SnapshotId: defaultID,