From 5c530123ab0ccdd64a9489ddd7e695ff2e7f4d99 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 2 Mar 2022 09:19:01 +0300 Subject: [PATCH] [#195] Fix lint errors Signed-off-by: Denis Kirillov --- api/handler/handlers_test.go | 2 +- api/handler/locking_test.go | 8 ++++---- api/layer/versioning.go | 12 ------------ 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/api/handler/handlers_test.go b/api/handler/handlers_test.go index 495c2683..3137652d 100644 --- a/api/handler/handlers_test.go +++ b/api/handler/handlers_test.go @@ -130,7 +130,7 @@ func prepareTestRequest(t *testing.T, bktName, objName string, body interface{}) require.NoError(t, err) w := httptest.NewRecorder() - r := httptest.NewRequest(http.MethodPut, defaultUrl, bytes.NewReader(rawBody)) + r := httptest.NewRequest(http.MethodPut, defaultURL, bytes.NewReader(rawBody)) reqInfo := api.NewReqInfo(w, r, api.ObjectRequest{Bucket: bktName, Object: objName}) r = r.WithContext(api.SetReqInfo(r.Context(), reqInfo)) diff --git a/api/handler/locking_test.go b/api/handler/locking_test.go index 754c0dbd..07c06618 100644 --- a/api/handler/locking_test.go +++ b/api/handler/locking_test.go @@ -17,7 +17,7 @@ import ( "github.com/stretchr/testify/require" ) -const defaultUrl = "http://localhost/" +const defaultURL = "http://localhost/" func TestFormObjectLock(t *testing.T) { for _, tc := range []struct { @@ -63,7 +63,7 @@ func TestFormObjectLock(t *testing.T) { name: "invalid time format error", bktInfo: &data.BucketInfo{ObjectLockEnabled: true}, header: map[string][]string{ - api.AmzObjectLockRetainUntilDate: {time.Now().Format(time.Layout)}, + api.AmzObjectLockRetainUntilDate: {time.Now().Format(time.RFC822)}, }, expectedError: true, }, @@ -351,7 +351,7 @@ func TestPutBucketLockConfigurationHandler(t *testing.T) { require.NoError(t, err) w := httptest.NewRecorder() - r := httptest.NewRequest(http.MethodPut, defaultUrl, bytes.NewReader(body)) + r := httptest.NewRequest(http.MethodPut, defaultURL, bytes.NewReader(body)) r = r.WithContext(api.SetReqInfo(r.Context(), api.NewReqInfo(w, r, api.ObjectRequest{Bucket: tc.bucket}))) hc.Handler().PutBucketObjectLockConfigHandler(w, r) @@ -425,7 +425,7 @@ func TestGetBucketLockConfigurationHandler(t *testing.T) { } { t.Run(tc.name, func(t *testing.T) { w := httptest.NewRecorder() - r := httptest.NewRequest(http.MethodPut, defaultUrl, bytes.NewReader(nil)) + r := httptest.NewRequest(http.MethodPut, defaultURL, bytes.NewReader(nil)) r = r.WithContext(api.SetReqInfo(r.Context(), api.NewReqInfo(w, r, api.ObjectRequest{Bucket: tc.bucket}))) hc.Handler().GetBucketObjectLockConfigHandler(w, r) diff --git a/api/layer/versioning.go b/api/layer/versioning.go index cbffd4e4..9bebe362 100644 --- a/api/layer/versioning.go +++ b/api/layer/versioning.go @@ -398,18 +398,6 @@ func contains(list []string, elem string) bool { return false } -func objectInfoToBucketSettings(info *data.ObjectInfo) *data.BucketSettings { - res := &data.BucketSettings{} - - enabled, ok := info.Headers[attrSettingsVersioningEnabled] - if ok { - if parsed, err := strconv.ParseBool(enabled); err == nil { - res.VersioningEnabled = parsed - } - } - return res -} - func (n *layer) checkVersionsExist(ctx context.Context, bkt *data.BucketInfo, obj *VersionedObject) (*data.ObjectInfo, error) { versions, err := n.headVersions(ctx, bkt, obj.Name) if err != nil {