Class: GitlabConfig::S3ConfigurationSource
- Inherits:
-
Object
- Object
- GitlabConfig::S3ConfigurationSource
- Defined in:
- lib/gitlab_config/source/s3.rb
Overview
Read the configuration from a file in an s3 bucket
Instance Attribute Summary collapse
-
#iam ⇒ Object
readonly
Returns the value of attribute iam.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
-
#get_configuration(options) ⇒ Object
Get configuration will download the file read it.
-
#initialize(config) ⇒ S3ConfigurationSource
constructor
A new instance of S3ConfigurationSource.
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
#iam ⇒ Object (readonly)
Returns the value of attribute iam.
10 11 12 |
# File 'lib/gitlab_config/source/s3.rb', line 10 def iam @iam end |
#region ⇒ Object (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() Aws.config.update({region: @region}) download_path = "/tmp/#{options.fetch(:file)}" object = Aws::S3::Object.new(.fetch(:bucket), .fetch(:file), client: client) object.get(response_target: download_path) YAML.load_file(download_path) end |