Class: GitlabConfig::S3ConfigurationSource

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_config/source/s3.rb

Overview

Read the configuration from a file in an s3 bucket

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ S3ConfigurationSource



12
13
14
15
16
17
# File 'lib/gitlab_config/source/s3.rb', line 12

def initialize(config)
  @region = config.fetch(:region)
  @iam = config.fetch(:iam, nil)
  @role_arn = config.fetch(:arn, nil)
  @role_session = config.fetch(:session, nil)
end

Instance Attribute Details

#iamObject (readonly)

Returns the value of attribute iam.



10
11
12
# File 'lib/gitlab_config/source/s3.rb', line 10

def iam
  @iam
end

#regionObject (readonly)

Returns the value of attribute region.



10
11
12
# File 'lib/gitlab_config/source/s3.rb', line 10

def region
  @region
end

Instance Method Details

#get_configuration(options) ⇒ Object

Get configuration will download the file read it



20
21
22
23
24
25
26
27
28
# File 'lib/gitlab_config/source/s3.rb', line 20

def get_configuration(options)
  Aws.config.update({region: @region})
  download_path = "/tmp/#{options.fetch(:file)}"

  object = Aws::S3::Object.new(options.fetch(:bucket), options.fetch(:file), client: client)
  object.get(response_target: download_path)

  YAML.load_file(download_path)
end