backend: move PutBucketAcl next to bucket methods

This commit is contained in:
Ben McClelland
2023-05-24 14:15:31 -07:00
parent 296aeb1960
commit 0121ea6c7f
3 changed files with 4 additions and 80 deletions

View File

@@ -20,6 +20,7 @@ type Backend interface {
HeadBucket(bucket string) (*s3.HeadBucketOutput, error)
GetBucketAcl(bucket string) (*s3.GetBucketAclOutput, error)
PutBucket(bucket string) error
PutBucketAcl(*s3.PutBucketAclInput) error
DeleteBucket(bucket string) error
CreateMultipartUpload(*s3.CreateMultipartUploadInput) (*s3.CreateMultipartUploadOutput, error)
@@ -40,13 +41,11 @@ type Backend interface {
ListObjectsV2(bucket, prefix, marker, delim string, maxkeys int) (*s3.ListObjectsV2Output, error)
DeleteObject(bucket, object string) error
DeleteObjects(bucket string, objects *s3.DeleteObjectsInput) error
PutBucketAcl(*s3.PutBucketAclInput) error
PutObjectAcl(*s3.PutObjectAclInput) error
RestoreObject(bucket, object string, restoreRequest *s3.RestoreObjectInput) error
UploadPart(bucket, object, uploadId string, Body io.ReadSeeker) (*s3.UploadPartOutput, error)
UploadPartCopy(*s3.UploadPartCopyInput) (*s3.UploadPartCopyOutput, error)
IsTaggingSupported() bool
GetTags(bucket, object string) (map[string]string, error)
SetTags(bucket, object string, tags map[string]string) error
RemoveTags(bucket, object string) error
@@ -151,13 +150,12 @@ func (BackendUnsupported) ListObjectsV2(bucket, prefix, marker, delim string, ma
return nil, s3err.GetAPIError(s3err.ErrNotImplemented)
}
func (BackendUnsupported) IsTaggingSupported() bool { return false }
func (BackendUnsupported) GetTags(bucket, object string) (map[string]string, error) {
return nil, fmt.Errorf("not supported")
return nil, s3err.GetAPIError(s3err.ErrNotImplemented)
}
func (BackendUnsupported) SetTags(bucket, object string, tags map[string]string) error {
return fmt.Errorf("not supported")
return s3err.GetAPIError(s3err.ErrNotImplemented)
}
func (BackendUnsupported) RemoveTags(bucket, object string) error {
return fmt.Errorf("not supported")
return s3err.GetAPIError(s3err.ErrNotImplemented)
}

View File

@@ -68,9 +68,6 @@ var _ Backend = &BackendMock{}
// HeadObjectFunc: func(bucket string, object string, etag string) (*s3.HeadObjectOutput, error) {
// panic("mock out the HeadObject method")
// },
// IsTaggingSupportedFunc: func() bool {
// panic("mock out the IsTaggingSupported method")
// },
// ListBucketsFunc: func() (*s3.ListBucketsOutput, error) {
// panic("mock out the ListBuckets method")
// },
@@ -177,9 +174,6 @@ type BackendMock struct {
// HeadObjectFunc mocks the HeadObject method.
HeadObjectFunc func(bucket string, object string, etag string) (*s3.HeadObjectOutput, error)
// IsTaggingSupportedFunc mocks the IsTaggingSupported method.
IsTaggingSupportedFunc func() bool
// ListBucketsFunc mocks the ListBuckets method.
ListBucketsFunc func() (*s3.ListBucketsOutput, error)
@@ -359,9 +353,6 @@ type BackendMock struct {
// Etag is the etag argument value.
Etag string
}
// IsTaggingSupported holds details about calls to the IsTaggingSupported method.
IsTaggingSupported []struct {
}
// ListBuckets holds details about calls to the ListBuckets method.
ListBuckets []struct {
}
@@ -508,7 +499,6 @@ type BackendMock struct {
lockGetTags sync.RWMutex
lockHeadBucket sync.RWMutex
lockHeadObject sync.RWMutex
lockIsTaggingSupported sync.RWMutex
lockListBuckets sync.RWMutex
lockListMultipartUploads sync.RWMutex
lockListObjectParts sync.RWMutex
@@ -1131,33 +1121,6 @@ func (mock *BackendMock) HeadObjectCalls() []struct {
return calls
}
// IsTaggingSupported calls IsTaggingSupportedFunc.
func (mock *BackendMock) IsTaggingSupported() bool {
if mock.IsTaggingSupportedFunc == nil {
panic("BackendMock.IsTaggingSupportedFunc: method is nil but Backend.IsTaggingSupported was just called")
}
callInfo := struct {
}{}
mock.lockIsTaggingSupported.Lock()
mock.calls.IsTaggingSupported = append(mock.calls.IsTaggingSupported, callInfo)
mock.lockIsTaggingSupported.Unlock()
return mock.IsTaggingSupportedFunc()
}
// IsTaggingSupportedCalls gets all the calls that were made to IsTaggingSupported.
// Check the length with:
//
// len(mockedBackend.IsTaggingSupportedCalls())
func (mock *BackendMock) IsTaggingSupportedCalls() []struct {
} {
var calls []struct {
}
mock.lockIsTaggingSupported.RLock()
calls = mock.calls.IsTaggingSupported
mock.lockIsTaggingSupported.RUnlock()
return calls
}
// ListBuckets calls ListBucketsFunc.
func (mock *BackendMock) ListBuckets() (*s3.ListBucketsOutput, error) {
if mock.ListBucketsFunc == nil {

View File

@@ -69,9 +69,6 @@ var _ backend.Backend = &BackendMock{}
// HeadObjectFunc: func(bucket string, object string, etag string) (*s3.HeadObjectOutput, error) {
// panic("mock out the HeadObject method")
// },
// IsTaggingSupportedFunc: func() bool {
// panic("mock out the IsTaggingSupported method")
// },
// ListBucketsFunc: func() (*s3.ListBucketsOutput, error) {
// panic("mock out the ListBuckets method")
// },
@@ -178,9 +175,6 @@ type BackendMock struct {
// HeadObjectFunc mocks the HeadObject method.
HeadObjectFunc func(bucket string, object string, etag string) (*s3.HeadObjectOutput, error)
// IsTaggingSupportedFunc mocks the IsTaggingSupported method.
IsTaggingSupportedFunc func() bool
// ListBucketsFunc mocks the ListBuckets method.
ListBucketsFunc func() (*s3.ListBucketsOutput, error)
@@ -360,9 +354,6 @@ type BackendMock struct {
// Etag is the etag argument value.
Etag string
}
// IsTaggingSupported holds details about calls to the IsTaggingSupported method.
IsTaggingSupported []struct {
}
// ListBuckets holds details about calls to the ListBuckets method.
ListBuckets []struct {
}
@@ -509,7 +500,6 @@ type BackendMock struct {
lockGetTags sync.RWMutex
lockHeadBucket sync.RWMutex
lockHeadObject sync.RWMutex
lockIsTaggingSupported sync.RWMutex
lockListBuckets sync.RWMutex
lockListMultipartUploads sync.RWMutex
lockListObjectParts sync.RWMutex
@@ -1132,33 +1122,6 @@ func (mock *BackendMock) HeadObjectCalls() []struct {
return calls
}
// IsTaggingSupported calls IsTaggingSupportedFunc.
func (mock *BackendMock) IsTaggingSupported() bool {
if mock.IsTaggingSupportedFunc == nil {
panic("BackendMock.IsTaggingSupportedFunc: method is nil but Backend.IsTaggingSupported was just called")
}
callInfo := struct {
}{}
mock.lockIsTaggingSupported.Lock()
mock.calls.IsTaggingSupported = append(mock.calls.IsTaggingSupported, callInfo)
mock.lockIsTaggingSupported.Unlock()
return mock.IsTaggingSupportedFunc()
}
// IsTaggingSupportedCalls gets all the calls that were made to IsTaggingSupported.
// Check the length with:
//
// len(mockedBackend.IsTaggingSupportedCalls())
func (mock *BackendMock) IsTaggingSupportedCalls() []struct {
} {
var calls []struct {
}
mock.lockIsTaggingSupported.RLock()
calls = mock.calls.IsTaggingSupported
mock.lockIsTaggingSupported.RUnlock()
return calls
}
// ListBuckets calls ListBucketsFunc.
func (mock *BackendMock) ListBuckets() (*s3.ListBucketsOutput, error) {
if mock.ListBucketsFunc == nil {