From c2150bd772aba0884ac48b3b49e6208f6104615d Mon Sep 17 00:00:00 2001 From: Patrik Cyvoct Date: Thu, 20 Aug 2020 11:44:50 +0200 Subject: [PATCH] chore: bump scaleway-sdk-go to fix mishandled 404 Signed-off-by: Patrik Cyvoct --- driver/controller.go | 74 +++++++++++++++++++++++++------------------ driver/sanity_test.go | 2 +- go.mod | 2 +- go.sum | 4 +-- 4 files changed, 48 insertions(+), 34 deletions(-) diff --git a/driver/controller.go b/driver/controller.go index 37d241e..035afca 100644 --- a/driver/controller.go +++ b/driver/controller.go @@ -567,19 +567,24 @@ func (d *controllerService) CreateSnapshot(ctx context.Context, req *csi.CreateS } if snapshot != nil { - creationTime, err := ptypes.TimestampProto(snapshot.CreationDate) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) + snapshotResp := &csi.Snapshot{ + SizeBytes: int64(snapshot.Size), // TODO(pcyvoct) ugly cast + SnapshotId: scaleway.ExpandSnapshotID(snapshot), + SourceVolumeId: sourceVolumeZone.String() + "/" + sourceVolumeID, + ReadyToUse: snapshot.State == instance.SnapshotStateAvailable, + } + + if snapshot.CreationDate != nil { + creationTime, err := ptypes.TimestampProto(*snapshot.CreationDate) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + snapshotResp.CreationTime = creationTime + } return &csi.CreateSnapshotResponse{ - Snapshot: &csi.Snapshot{ - SizeBytes: int64(snapshot.Size), // TODO(pcyvoct) ugly cast - SnapshotId: scaleway.ExpandSnapshotID(snapshot), - SourceVolumeId: sourceVolumeZone.String() + "/" + sourceVolumeID, - CreationTime: creationTime, - ReadyToUse: snapshot.State == instance.SnapshotStateAvailable, - }, + Snapshot: snapshotResp, }, nil } @@ -593,19 +598,23 @@ func (d *controllerService) CreateSnapshot(ctx context.Context, req *csi.CreateS return nil, status.Error(codes.Internal, err.Error()) } - creationTime, err := ptypes.TimestampProto(snapshotResp.Snapshot.CreationDate) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) + snapshotProtoResp := &csi.Snapshot{ + SizeBytes: int64(snapshotResp.Snapshot.Size), // TODO(pcyvoct) ugly cast + SnapshotId: scaleway.ExpandSnapshotID(snapshotResp.Snapshot), + SourceVolumeId: sourceVolumeZone.String() + "/" + sourceVolumeID, + ReadyToUse: snapshotResp.Snapshot.State == instance.SnapshotStateAvailable, + } + + if snapshotResp.Snapshot.CreationDate != nil { + creationTime, err := ptypes.TimestampProto(*snapshotResp.Snapshot.CreationDate) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + snapshotProtoResp.CreationTime = creationTime } return &csi.CreateSnapshotResponse{ - Snapshot: &csi.Snapshot{ - SizeBytes: int64(snapshotResp.Snapshot.Size), // TODO(pcyvoct) ugly cast - SnapshotId: scaleway.ExpandSnapshotID(snapshotResp.Snapshot), - SourceVolumeId: sourceVolumeZone.String() + "/" + sourceVolumeID, - CreationTime: creationTime, - ReadyToUse: snapshotResp.Snapshot.State == instance.SnapshotStateAvailable, - }, + Snapshot: snapshotProtoResp, }, nil } @@ -691,18 +700,23 @@ func (d *controllerService) ListSnapshots(ctx context.Context, req *csi.ListSnap sourceID = snap.Zone.String() + "/" + snap.BaseVolume.ID } - creationTime, err := ptypes.TimestampProto(snap.CreationDate) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) + snapshotProtoResp := &csi.Snapshot{ + SizeBytes: int64(snap.Size), // TODO(pcyvoct) ugly cast + SnapshotId: scaleway.ExpandSnapshotID(snap), + SourceVolumeId: sourceID, + ReadyToUse: snap.State == instance.SnapshotStateAvailable, + } + + if snap.CreationDate != nil { + creationTime, err := ptypes.TimestampProto(*snap.CreationDate) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + snapshotProtoResp.CreationTime = creationTime } + snapshotsEntries = append(snapshotsEntries, &csi.ListSnapshotsResponse_Entry{ - Snapshot: &csi.Snapshot{ - SizeBytes: int64(snap.Size), // TODO(pcyvoct) ugly cast - SnapshotId: scaleway.ExpandSnapshotID(snap), - SourceVolumeId: sourceID, - CreationTime: creationTime, - ReadyToUse: snap.State == instance.SnapshotStateAvailable, - }, + Snapshot: snapshotProtoResp, }) } diff --git a/driver/sanity_test.go b/driver/sanity_test.go index 849eb17..7089ab3 100644 --- a/driver/sanity_test.go +++ b/driver/sanity_test.go @@ -287,7 +287,7 @@ func (s *fakeHelper) CreateSnapshot(req *instance.CreateSnapshotRequest, opts .. ID: volume.ID, Name: volume.Name, } - snapshot.CreationDate = time.Now() + snapshot.CreationDate = scw.TimePtr(time.Now()) s.snapshotsMap[snapshot.ID] = snapshot return &instance.CreateSnapshotResponse{ diff --git a/go.mod b/go.mod index 0e232df..63a20ee 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/golang/protobuf v1.3.2 github.com/google/uuid v1.1.1 github.com/kubernetes-csi/csi-test/v3 v3.1.0 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200814130755-648e470a1d42 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200820094136-e5e36003a999 golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056 google.golang.org/grpc v1.25.1 k8s.io/klog v1.0.0 diff --git a/go.sum b/go.sum index c7026e6..fc19d18 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200814130755-648e470a1d42 h1:U4V579TXpwXspEBuEOh4+bDDVLLtMVdQA4sugdKl/QU= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200814130755-648e470a1d42/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200820094136-e5e36003a999 h1:JfTFkJt8n60HtsfHw5e6A1gim8W2kQ57uOXLLQES40w= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200820094136-e5e36003a999/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=