Class: ObjectStorage::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/object_storage/config.rb

Constant Summary collapse

AWS_PROVIDER =
'AWS'
AZURE_PROVIDER =
'AzureRM'
GOOGLE_PROVIDER =
'Google'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Config

Returns a new instance of Config.


11
12
13
# File 'lib/object_storage/config.rb', line 11

def initialize(options)
  @options = options.to_hash.deep_symbolize_keys
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.


9
10
11
# File 'lib/object_storage/config.rb', line 9

def options
  @options
end

Instance Method Details

#aws?Boolean

AWS-specific options

Returns:

  • (Boolean)

36
37
38
# File 'lib/object_storage/config.rb', line 36

def aws?
  provider == AWS_PROVIDER
end

#aws_server_side_encryption_enabled?Boolean

Returns:

  • (Boolean)

83
84
85
# File 'lib/object_storage/config.rb', line 83

def aws_server_side_encryption_enabled?
  aws? && server_side_encryption.present?
end

#azure?Boolean

Returns:

  • (Boolean)

71
72
73
# File 'lib/object_storage/config.rb', line 71

def azure?
  provider == AZURE_PROVIDER
end

#azure_storage_domainObject

Begin Azure-specific options


62
63
64
# File 'lib/object_storage/config.rb', line 62

def azure_storage_domain
  credentials[:azure_storage_domain]
end

#bucketObject


27
28
29
# File 'lib/object_storage/config.rb', line 27

def bucket
  options[:remote_directory]
end

#consolidated_settings?Boolean

Returns:

  • (Boolean)

31
32
33
# File 'lib/object_storage/config.rb', line 31

def consolidated_settings?
  options.fetch(:consolidated_settings, false)
end

#credentialsObject


15
16
17
# File 'lib/object_storage/config.rb', line 15

def credentials
  @credentials ||= options[:connection] || {}
end

#enabled?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'lib/object_storage/config.rb', line 23

def enabled?
  options[:enabled]
end

#fog_attributesObject


75
76
77
78
79
80
81
# File 'lib/object_storage/config.rb', line 75

def fog_attributes
  @fog_attributes ||= begin
    return {} unless aws_server_side_encryption_enabled?

    aws_server_side_encryption_headers.compact
  end
end

#google?Boolean

End Azure-specific options

Returns:

  • (Boolean)

67
68
69
# File 'lib/object_storage/config.rb', line 67

def google?
  provider == GOOGLE_PROVIDER
end

#providerObject


56
57
58
# File 'lib/object_storage/config.rb', line 56

def provider
  credentials[:provider].to_s
end

#server_side_encryptionObject


48
49
50
# File 'lib/object_storage/config.rb', line 48

def server_side_encryption
  storage_options[:server_side_encryption]
end

#server_side_encryption_kms_key_idObject


52
53
54
# File 'lib/object_storage/config.rb', line 52

def server_side_encryption_kms_key_id
  storage_options[:server_side_encryption_kms_key_id]
end

#storage_optionsObject


19
20
21
# File 'lib/object_storage/config.rb', line 19

def storage_options
  @storage_options ||= options[:storage_options] || {}
end

#use_iam_profile?Boolean

Returns:

  • (Boolean)

40
41
42
# File 'lib/object_storage/config.rb', line 40

def use_iam_profile?
  Gitlab::Utils.to_boolean(credentials[:use_iam_profile], default: false)
end

#use_path_style?Boolean

Returns:

  • (Boolean)

44
45
46
# File 'lib/object_storage/config.rb', line 44

def use_path_style?
  Gitlab::Utils.to_boolean(credentials[:path_style], default: false)
end