diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-23 21:42:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-23 21:42:02 +0300 |
commit | 5a1541a44f745cf9ae4121d6919a1530a7212afe (patch) | |
tree | 3841ea24d9eaa1e5521f168348af3fd409aab962 /lib/object_storage | |
parent | f1bc6c9f752e5dcf11f5798c70498e9ae4a8e3ec (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-ee
Diffstat (limited to 'lib/object_storage')
-rw-r--r-- | lib/object_storage/config.rb | 36 | ||||
-rw-r--r-- | lib/object_storage/direct_upload.rb | 4 |
2 files changed, 2 insertions, 38 deletions
diff --git a/lib/object_storage/config.rb b/lib/object_storage/config.rb index 0e6408b4917..f933d4e4866 100644 --- a/lib/object_storage/config.rb +++ b/lib/object_storage/config.rb @@ -2,8 +2,6 @@ module ObjectStorage class Config - include Gitlab::Utils::StrongMemoize - AWS_PROVIDER = 'AWS' AZURE_PROVIDER = 'AzureRM' GOOGLE_PROVIDER = 'Google' @@ -68,36 +66,6 @@ module ObjectStorage def provider credentials[:provider].to_s end - - # This method converts fog-aws parameters to an endpoint for the - # Workhorse S3 client. - def s3_endpoint - strong_memoize(:s3_endpoint) do - # We could omit this line and let the following code handle this, but - # this will ensure that working configurations that use `endpoint` - # will continue to work. - next credentials[:endpoint] if credentials[:endpoint].present? - - generate_s3_endpoint_from_credentials - end - end - - def generate_s3_endpoint_from_credentials - # fog-aws has special handling of the host, region, scheme, etc: - # https://github.com/fog/fog-aws/blob/c7a11ba377a76d147861d0e921eb1e245bc11b6c/lib/fog/aws/storage.rb#L440-L449 - # Rather than reimplement this, we derive it from a sample GET URL. - url = fog_connection.get_object_url(bucket, "tmp", nil) - uri = ::Addressable::URI.parse(url) - - return unless uri&.scheme && uri&.host - - endpoint = "#{uri.scheme}://#{uri.host}" - endpoint += ":#{uri.port}" if uri.port - endpoint - rescue ::URI::InvalidComponentError, ::Addressable::URI::InvalidURIError => e - Gitlab::ErrorTracking.track_exception(e) - nil - end # End AWS-specific options # Begin Azure-specific options @@ -123,10 +91,6 @@ module ObjectStorage end end - def fog_connection - @connection ||= ::Fog::Storage.new(credentials) - end - private # This returns a Hash of HTTP encryption headers to send along to S3. diff --git a/lib/object_storage/direct_upload.rb b/lib/object_storage/direct_upload.rb index 9fb4b571e06..7f1c30e574d 100644 --- a/lib/object_storage/direct_upload.rb +++ b/lib/object_storage/direct_upload.rb @@ -80,7 +80,7 @@ module ObjectStorage S3Config: { Bucket: bucket_name, Region: credentials[:region], - Endpoint: config.s3_endpoint, + Endpoint: credentials[:endpoint], PathStyle: config.use_path_style?, UseIamProfile: config.use_iam_profile?, ServerSideEncryption: config.server_side_encryption, @@ -229,7 +229,7 @@ module ObjectStorage end def connection - config.fog_connection + @connection ||= ::Fog::Storage.new(credentials) end end end |