Class: Import::Clients::ObjectStorage

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
lib/import/clients/object_storage.rb

Constant Summary collapse

ConnectionError =
Class.new(StandardError)
FOG_PROVIDER_MAP =
{
  aws: 'AWS',
  s3_compatible: 'AWS'
}.with_indifferent_access.freeze

Instance Method Summary collapse

Constructor Details

#initialize(provider:, bucket:, credentials:) ⇒ ObjectStorage

Returns a new instance of ObjectStorage.



15
16
17
18
19
# File 'lib/import/clients/object_storage.rb', line 15

def initialize(provider:, bucket:, credentials:)
  @provider = provider
  @bucket = bucket
  @credentials = credentials
end

Instance Method Details

#test_connection!Object

Raises:



21
22
23
24
25
26
27
28
29
# File 'lib/import/clients/object_storage.rb', line 21

def test_connection!
  status = storage.head_bucket(bucket).status

  return if status == 200

  raise ConnectionError, format(
    s_('OfflineTransfer|Object storage request responded with status %{status}'), status: status
  )
end