Use directories.new when getting S3 directory
Calling `Fog::Storage::AWS::Directories#get` requires the ListAllMyBuckets permission, but we can avoid that extra query and permission by initializing the directory with a specific bucket: https://stackoverflow.com/a/12288581/1992201
This commit is contained in:
parent
e242c8cd6b
commit
2bfc317492
3 changed files with 8 additions and 2 deletions
6
changelogs/unreleased/s3-directories-get.yml
Normal file
6
changelogs/unreleased/s3-directories-get.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
title: Allow 'rake gitlab:cleanup:remote_upload_files' to read bucket files without
|
||||
having permissions to see all buckets.
|
||||
merge_request: 23981
|
||||
author:
|
||||
type: fixed
|
|
@ -67,7 +67,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def remote_directory
|
||||
connection.directories.get(configuration['remote_directory'])
|
||||
connection.directories.new(key: configuration['remote_directory'])
|
||||
end
|
||||
|
||||
def connection
|
||||
|
|
|
@ -25,7 +25,7 @@ describe Gitlab::Cleanup::RemoteUploads do
|
|||
|
||||
expect(::Fog::Storage).to receive(:new).and_return(connection)
|
||||
|
||||
expect(connection).to receive(:directories).and_return(double(get: directory))
|
||||
expect(connection).to receive(:directories).and_return(double(new: directory))
|
||||
expect(directory).to receive(:files).and_return(remote_files)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue