From 3ac3f1cc9d4db2f76b8cbf3757b479f2b3fc416e Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Thu, 4 Aug 2022 21:31:33 +0400 Subject: [PATCH] [#577] Rename objectInfo.Version() to VersionID() Signed-off-by: Angira Kekteeva --- api/data/info.go | 6 +++--- api/handler/acl.go | 2 +- api/handler/delete_test.go | 26 +++++++++++++------------- api/handler/get.go | 2 +- api/handler/head.go | 2 +- api/handler/multipart_upload.go | 4 ++-- api/handler/put.go | 10 +++++----- api/layer/locking_test.go | 2 +- api/layer/versioning.go | 6 +++--- api/layer/versioning_test.go | 8 ++++---- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/api/data/info.go b/api/data/info.go index 445f7868a..8088b57cb 100644 --- a/api/data/info.go +++ b/api/data/info.go @@ -82,7 +82,7 @@ type ( func NotificationInfoFromObject(objInfo *ObjectInfo) *NotificationInfo { return &NotificationInfo{ Name: objInfo.Name, - Version: objInfo.Version(), + Version: objInfo.VersionID(), Size: objInfo.Size, HashSum: objInfo.HashSum, } @@ -98,8 +98,8 @@ func (b *BucketInfo) NotificationConfigurationObjectName() string { return bktNotificationConfigurationObject } -// Version returns object version from ObjectInfo. -func (o *ObjectInfo) Version() string { return o.ID.EncodeToString() } +// VersionID returns object version from ObjectInfo. +func (o *ObjectInfo) VersionID() string { return o.ID.EncodeToString() } // NiceName returns object name for cache. func (o *ObjectInfo) NiceName() string { return o.Bucket + "/" + o.Name } diff --git a/api/handler/acl.go b/api/handler/acl.go index 62381c4e6..89939a55e 100644 --- a/api/handler/acl.go +++ b/api/handler/acl.go @@ -307,7 +307,7 @@ func (h *handler) GetObjectACLHandler(w http.ResponseWriter, r *http.Request) { return } - if err = api.EncodeToResponse(w, h.encodeObjectACL(bucketACL, reqInfo.BucketName, objInfo.ObjectInfo.Version())); err != nil { + if err = api.EncodeToResponse(w, h.encodeObjectACL(bucketACL, reqInfo.BucketName, objInfo.ObjectInfo.VersionID())); err != nil { h.logAndSendError(w, "failed to encode response", reqInfo, err) } } diff --git a/api/handler/delete_test.go b/api/handler/delete_test.go index ed6731da4..b20106457 100644 --- a/api/handler/delete_test.go +++ b/api/handler/delete_test.go @@ -26,7 +26,7 @@ func TestDeleteBucket(t *testing.T) { require.True(t, isDeleteMarker) deleteBucket(t, tc, bktName, http.StatusConflict) - deleteObject(t, tc, bktName, objName, objInfo.Version()) + deleteObject(t, tc, bktName, objName, objInfo.VersionID()) deleteBucket(t, tc, bktName, http.StatusConflict) deleteObject(t, tc, bktName, objName, deleteMarkerVersion) deleteBucket(t, tc, bktName, http.StatusNoContent) @@ -86,13 +86,13 @@ func TestDeleteDeletedObject(t *testing.T) { bktName, objName := "bucket-versioned-for-removal", "object-to-delete" _, objInfo := createVersionedBucketAndObject(t, tc, bktName, objName) - versionID, isDeleteMarker := deleteObject(t, tc, bktName, objName, objInfo.Version()) + versionID, isDeleteMarker := deleteObject(t, tc, bktName, objName, objInfo.VersionID()) require.False(t, isDeleteMarker) - require.Equal(t, objInfo.Version(), versionID) + require.Equal(t, objInfo.VersionID(), versionID) versionID2, isDeleteMarker := deleteObject(t, tc, bktName, objName, versionID) require.False(t, isDeleteMarker) - require.Equal(t, objInfo.Version(), versionID2) + require.Equal(t, objInfo.VersionID(), versionID2) }) } @@ -106,9 +106,9 @@ func TestDeleteObjectVersioned(t *testing.T) { deleteObject(t, tc, bktName, objName, emptyVersion) checkNotFound(t, tc, bktName, objName, emptyVersion) - checkFound(t, tc, bktName, objName, objInfo.Version()) - deleteObject(t, tc, bktName, objName, objInfo.Version()) - checkNotFound(t, tc, bktName, objName, objInfo.Version()) + checkFound(t, tc, bktName, objName, objInfo.VersionID()) + deleteObject(t, tc, bktName, objName, objInfo.VersionID()) + checkNotFound(t, tc, bktName, objName, objInfo.VersionID()) require.False(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object exists but shouldn't") } @@ -141,7 +141,7 @@ func TestRemoveDeleteMarker(t *testing.T) { require.True(t, isDeleteMarker) checkNotFound(t, tc, bktName, objName, emptyVersion) - checkFound(t, tc, bktName, objName, objInfo.Version()) + checkFound(t, tc, bktName, objName, objInfo.VersionID()) deleteObject(t, tc, bktName, objName, deleteMarkerVersion) checkFound(t, tc, bktName, objName, emptyVersion) @@ -160,7 +160,7 @@ func TestDeleteObjectCombined(t *testing.T) { deleteObject(t, tc, bktName, objName, emptyVersion) checkNotFound(t, tc, bktName, objName, emptyVersion) - checkFound(t, tc, bktName, objName, objInfo.Version()) + checkFound(t, tc, bktName, objName, objInfo.VersionID()) require.True(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object doesn't exist but should") } @@ -180,7 +180,7 @@ func TestDeleteObjectSuspended(t *testing.T) { putBucketVersioning(t, tc, bktName, false) deleteObject(t, tc, bktName, objName, emptyVersion) - checkNotFound(t, tc, bktName, objName, objInfo.Version()) + checkNotFound(t, tc, bktName, objName, objInfo.VersionID()) require.False(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object exists but shouldn't") } @@ -213,9 +213,9 @@ func TestDeleteObjectFromListCache(t *testing.T) { versions := listObjectsV1(t, tc, bktName) require.Len(t, versions.Contents, 1) - checkFound(t, tc, bktName, objName, objInfo.Version()) - deleteObject(t, tc, bktName, objName, objInfo.Version()) - checkNotFound(t, tc, bktName, objName, objInfo.Version()) + checkFound(t, tc, bktName, objName, objInfo.VersionID()) + deleteObject(t, tc, bktName, objName, objInfo.VersionID()) + checkNotFound(t, tc, bktName, objName, objInfo.VersionID()) // check cache is clean after object removal versions = listObjectsV1(t, tc, bktName) diff --git a/api/handler/get.go b/api/handler/get.go index 6ea478f89..aa643861f 100644 --- a/api/handler/get.go +++ b/api/handler/get.go @@ -141,7 +141,7 @@ func (h *handler) GetObjectHandler(w http.ResponseWriter, r *http.Request) { t := &layer.ObjectVersion{ BktInfo: bktInfo, ObjectName: info.Name, - VersionID: info.Version(), + VersionID: info.VersionID(), } tagSet, lockInfo, err := h.obj.GetObjectTaggingAndLock(r.Context(), t, extendedInfo.NodeVersion) diff --git a/api/handler/head.go b/api/handler/head.go index 5ebd3aa1f..8f859a6ed 100644 --- a/api/handler/head.go +++ b/api/handler/head.go @@ -61,7 +61,7 @@ func (h *handler) HeadObjectHandler(w http.ResponseWriter, r *http.Request) { t := &layer.ObjectVersion{ BktInfo: bktInfo, ObjectName: info.Name, - VersionID: info.Version(), + VersionID: info.VersionID(), } tagSet, lockInfo, err := h.obj.GetObjectTaggingAndLock(r.Context(), t, extendedInfo.NodeVersion) diff --git a/api/handler/multipart_upload.go b/api/handler/multipart_upload.go index 4cf090c78..b1fb55d0c 100644 --- a/api/handler/multipart_upload.go +++ b/api/handler/multipart_upload.go @@ -363,7 +363,7 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http. t := &layer.ObjectVersion{ BktInfo: bktInfo, ObjectName: objInfo.Name, - VersionID: objInfo.Version(), + VersionID: objInfo.VersionID(), } if _, err = h.obj.PutObjectTagging(r.Context(), t, uploadData.TagSet); err != nil { h.logAndSendError(w, "could not put tagging file of completed multipart upload", reqInfo, err, additional...) @@ -420,7 +420,7 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http. } if bktSettings.VersioningEnabled() { - w.Header().Set(api.AmzVersionID, objInfo.Version()) + w.Header().Set(api.AmzVersionID, objInfo.VersionID()) } if err = api.EncodeToResponse(w, response); err != nil { diff --git a/api/handler/put.go b/api/handler/put.go index d65e7d582..223189257 100644 --- a/api/handler/put.go +++ b/api/handler/put.go @@ -255,7 +255,7 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) { t := &layer.ObjectVersion{ BktInfo: bktInfo, ObjectName: info.Name, - VersionID: info.Version(), + VersionID: info.VersionID(), } if tagSet != nil { if _, err = h.obj.PutObjectTagging(r.Context(), t, tagSet); err != nil { @@ -278,7 +278,7 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) { } if settings.VersioningEnabled() { - w.Header().Set(api.AmzVersionID, info.Version()) + w.Header().Set(api.AmzVersionID, info.VersionID()) } w.Header().Set(api.ETag, info.HashSum) @@ -382,7 +382,7 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) { t := &layer.ObjectVersion{ BktInfo: bktInfo, ObjectName: info.Name, - VersionID: info.Version(), + VersionID: info.VersionID(), } if tagSet != nil { @@ -408,7 +408,7 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) { if settings, err := h.obj.GetBucketSettings(r.Context(), bktInfo); err != nil { h.log.Warn("couldn't get bucket versioning", zap.String("bucket name", reqInfo.BucketName), zap.Error(err)) } else if settings.VersioningEnabled() { - w.Header().Set(api.AmzVersionID, info.Version()) + w.Header().Set(api.AmzVersionID, info.VersionID()) } if redirectURL := auth.MultipartFormValue(r, "success_action_redirect"); redirectURL != "" { @@ -508,7 +508,7 @@ func (h *handler) getNewEAclTable(r *http.Request, bktInfo *data.BucketInfo, obj resInfo := &resourceInfo{ Bucket: objInfo.Bucket, Object: objInfo.Name, - Version: objInfo.Version(), + Version: objInfo.VersionID(), } bktPolicy, err := aclToPolicy(objectACL, resInfo) diff --git a/api/layer/locking_test.go b/api/layer/locking_test.go index bd06d21ec..59b9fb59e 100644 --- a/api/layer/locking_test.go +++ b/api/layer/locking_test.go @@ -21,7 +21,7 @@ func TestObjectLockAttributes(t *testing.T) { p := &ObjectVersion{ BktInfo: tc.bktInfo, ObjectName: obj.Name, - VersionID: obj.Version(), + VersionID: obj.VersionID(), } lock := &data.ObjectLock{ diff --git a/api/layer/versioning.go b/api/layer/versioning.go index 2a3e16371..2ba013140 100644 --- a/api/layer/versioning.go +++ b/api/layer/versioning.go @@ -41,7 +41,7 @@ func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsPar } for i, obj := range allObjects { - if obj.ObjectInfo.Name >= p.KeyMarker && obj.ObjectInfo.Version() >= p.VersionIDMarker { + if obj.ObjectInfo.Name >= p.KeyMarker && obj.ObjectInfo.VersionID() >= p.VersionIDMarker { allObjects = allObjects[i:] break } @@ -52,11 +52,11 @@ func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsPar if len(allObjects) > p.MaxKeys { res.IsTruncated = true res.NextKeyMarker = allObjects[p.MaxKeys].ObjectInfo.Name - res.NextVersionIDMarker = allObjects[p.MaxKeys].ObjectInfo.Version() + res.NextVersionIDMarker = allObjects[p.MaxKeys].ObjectInfo.VersionID() allObjects = allObjects[:p.MaxKeys] res.KeyMarker = allObjects[p.MaxKeys-1].ObjectInfo.Name - res.VersionIDMarker = allObjects[p.MaxKeys-1].ObjectInfo.Version() + res.VersionIDMarker = allObjects[p.MaxKeys-1].ObjectInfo.VersionID() } res.Version, res.DeleteMarker = triageVersions(allObjects) diff --git a/api/layer/versioning_test.go b/api/layer/versioning_test.go index b4bf392c0..07ac368f9 100644 --- a/api/layer/versioning_test.go +++ b/api/layer/versioning_test.go @@ -251,7 +251,7 @@ func TestGetUnversioned(t *testing.T) { resInfo, buffer := tc.getObject(tc.obj, UnversionedObjectVersionID, false) require.Equal(t, objContent, buffer) - require.Equal(t, objInfo.Version(), resInfo.Version()) + require.Equal(t, objInfo.VersionID(), resInfo.VersionID()) } func TestVersioningDeleteSpecificObjectVersion(t *testing.T) { @@ -268,8 +268,8 @@ func TestVersioningDeleteSpecificObjectVersion(t *testing.T) { objV3Content := []byte("content obj1 v3") objV3Info := tc.putObject(objV3Content) - tc.deleteObject(tc.obj, objV2Info.Version(), settings) - tc.getObject(tc.obj, objV2Info.Version(), true) + tc.deleteObject(tc.obj, objV2Info.VersionID(), settings) + tc.getObject(tc.obj, objV2Info.VersionID(), true) _, buffer3 := tc.getObject(tc.obj, "", false) require.Equal(t, objV3Content, buffer3) @@ -286,7 +286,7 @@ func TestVersioningDeleteSpecificObjectVersion(t *testing.T) { resInfo, buffer := tc.getObject(tc.obj, "", false) require.Equal(t, objV3Content, buffer) - require.Equal(t, objV3Info.Version(), resInfo.Version()) + require.Equal(t, objV3Info.VersionID(), resInfo.VersionID()) } func TestNoVersioningDeleteObject(t *testing.T) {