Skip to content

Commit

Permalink
Merge pull request #1240 from huww98/rm-old-protobuf
Browse files Browse the repository at this point in the history
remove dep on old github.com/golang/protobuf
  • Loading branch information
k8s-ci-robot authored Dec 19, 2024
2 parents 78d4576 + f7ec651 commit 71912a2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require (
github.com/go-logr/logr v1.4.1
github.com/go-ping/ping v0.0.0-20201022122018-3977ed72668a
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/google/go-cmp v0.6.0
github.com/jarcoal/httpmock v1.3.1
github.com/kubernetes-csi/csi-lib-utils v0.7.1
Expand Down Expand Up @@ -61,6 +60,7 @@ require (
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
Expand Down
5 changes: 2 additions & 3 deletions pkg/disk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/common"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/features"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/utils"
Expand Down Expand Up @@ -782,13 +781,13 @@ func newListSnapshotsResponse(snapshots []ecs.Snapshot, nextToken string) (*csi.

func formatCSISnapshot(ecsSnapshot *ecs.Snapshot) (*csi.Snapshot, error) {
// creationTime == "" if created by snapshotGroup
var creationTime *timestamp.Timestamp
var creationTime *timestamppb.Timestamp
if ecsSnapshot.CreationTime != "" {
t, err := time.Parse(time.RFC3339, ecsSnapshot.CreationTime)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to parse snapshot creation time: %s", ecsSnapshot.CreationTime)
}
creationTime = &timestamp.Timestamp{Seconds: t.Unix()}
creationTime = timestamppb.New(t)
}

var sizeGB int64
Expand Down
8 changes: 4 additions & 4 deletions pkg/disk/group_volume_snapshot_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/common"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
)
Expand Down Expand Up @@ -101,7 +101,7 @@ func formatGroupSnapshot(groupSnapshot *ecs.SnapshotGroup) (*csi.VolumeGroupSnap
if err != nil {
return nil, fmt.Errorf("failed to parse groupSnapshot creation time: %s", groupSnapshot.CreationTime)
}
creationTime := timestamp.Timestamp{Seconds: t.Unix()}
creationTime := timestamppb.New(t)

readyToUse := groupSnapshot.Status == SnapshotStatusAccomplished
snapshots := []*csi.Snapshot{}
Expand All @@ -110,7 +110,7 @@ func formatGroupSnapshot(groupSnapshot *ecs.SnapshotGroup) (*csi.VolumeGroupSnap
if err != nil {
return nil, err
}
snapshot.CreationTime = &creationTime
snapshot.CreationTime = creationTime
snapshot.GroupSnapshotId = groupSnapshot.SnapshotGroupId
if !snapshot.ReadyToUse {
// set readyToUse for groupsnapshots according to each snapshot status
Expand All @@ -122,7 +122,7 @@ func formatGroupSnapshot(groupSnapshot *ecs.SnapshotGroup) (*csi.VolumeGroupSnap
return &csi.VolumeGroupSnapshot{
GroupSnapshotId: groupSnapshot.SnapshotGroupId,
Snapshots: snapshots,
CreationTime: &creationTime,
CreationTime: creationTime,
ReadyToUse: readyToUse,
}, nil
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/disk/group_volume_snapshot_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/common"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/types/known/timestamppb"
)

func Test_parseGroupSnapshotAnnotations(t *testing.T) {
Expand Down Expand Up @@ -67,19 +67,19 @@ func Test_formatGroupSnapshot(t *testing.T) {
{
SnapshotId: "snapshot1",
ReadyToUse: true,
CreationTime: &timestamp.Timestamp{Seconds: stamp.Unix()},
CreationTime: timestamppb.New(stamp),
GroupSnapshotId: "snapshotGroup1",
SizeBytes: 10 * 1024 * 1024 * 1024,
},
{
SnapshotId: "snapshot2",
ReadyToUse: false,
CreationTime: &timestamp.Timestamp{Seconds: stamp.Unix()},
CreationTime: timestamppb.New(stamp),
GroupSnapshotId: "snapshotGroup1",
SizeBytes: 10 * 1024 * 1024 * 1024,
},
},
CreationTime: &timestamp.Timestamp{Seconds: stamp.Unix()},
CreationTime: timestamppb.New(stamp),
ReadyToUse: false,
}

Expand Down

0 comments on commit 71912a2

Please sign in to comment.