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'
LOCATIONS =
{
  artifacts: Gitlab.config.artifacts,
  ci_secure_files: Gitlab.config.ci_secure_files,
  dependency_proxy: Gitlab.config.dependency_proxy,
  external_diffs: Gitlab.config.external_diffs,
  lfs: Gitlab.config.lfs,
  packages: Gitlab.config.packages,
  pages: Gitlab.config.pages,
  terraform_state: Gitlab.config.terraform_state,
  uploads: Gitlab.config.uploads
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Config

Returns a new instance of Config.



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

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/object_storage/config.rb', line 21

def options
  @options
end

Instance Method Details

#aws?Boolean

AWS-specific options

Returns:

  • (Boolean)


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

def aws?
  provider == AWS_PROVIDER
end

#aws_server_side_encryption_enabled?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/object_storage/config.rb', line 95

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

#azure?Boolean

Returns:

  • (Boolean)


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

def azure?
  provider == AZURE_PROVIDER
end

#azure_storage_domainObject

Begin Azure-specific options



74
75
76
# File 'lib/object_storage/config.rb', line 74

def azure_storage_domain
  credentials[:azure_storage_domain]
end

#bucketObject



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

def bucket
  options[:remote_directory]
end

#consolidated_settings?Boolean

Returns:

  • (Boolean)


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

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

#credentialsObject



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

def credentials
  @credentials ||= connection_params
end

#enabled?Boolean

Returns:

  • (Boolean)


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

def enabled?
  options[:enabled]
end

#fog_attributesObject



87
88
89
90
91
92
93
# File 'lib/object_storage/config.rb', line 87

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)


79
80
81
# File 'lib/object_storage/config.rb', line 79

def google?
  provider == GOOGLE_PROVIDER
end

#providerObject



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

def provider
  credentials[:provider].to_s
end

#server_side_encryptionObject



60
61
62
# File 'lib/object_storage/config.rb', line 60

def server_side_encryption
  storage_options[:server_side_encryption]
end

#server_side_encryption_kms_key_idObject



64
65
66
# File 'lib/object_storage/config.rb', line 64

def server_side_encryption_kms_key_id
  storage_options[:server_side_encryption_kms_key_id]
end

#storage_optionsObject



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

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

#use_iam_profile?Boolean

Returns:

  • (Boolean)


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

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

#use_path_style?Boolean

Returns:

  • (Boolean)


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

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