Class: AwsAssumeRole::ProfileConfiguration
- Inherits:
-
Object
- Object
- AwsAssumeRole::ProfileConfiguration
- Extended by:
- Dry::Initializer
- Includes:
- Logging
- Defined in:
- lib/aws_assume_role/profile_configuration.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
writeonly
Sets the attribute credentials.
Class Method Summary collapse
- .merge_mfa_variable(options) ⇒ Object
- .new_from_cli(global_options, options, args) ⇒ Object
- .new_from_credential_provider(options = {}, credentials: nil, delete: []) ⇒ Object
- .new_from_credential_provider_initialization(options) ⇒ Object
Instance Method Summary collapse
Methods included from Logging
Instance Attribute Details
#credentials=(value) ⇒ Object (writeonly)
Sets the attribute credentials
28 29 30 |
# File 'lib/aws_assume_role/profile_configuration.rb', line 28 def credentials=(value) @credentials = value end |
Class Method Details
.merge_mfa_variable(options) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/aws_assume_role/profile_configuration.rb', line 30 def self.merge_mfa_variable() new_hash = .key?(:mfa_serial) ? .merge(serial_number: [:mfa_serial]) : new_hash[:use_mfa] ||= new_hash.fetch(:serial_number, nil) ? true : false if new_hash.key?(:serial_number) && new_hash[:serial_number] == "automatic" new_hash.delete(:serial_number) end new_hash end |
.new_from_cli(global_options, options, args) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/aws_assume_role/profile_configuration.rb', line 39 def self.new_from_cli(, , args) = .merge = .map do |k, v| [k.to_s.underscore.to_sym, v] end.to_h [:args] = args new merge_mfa_variable() end |
.new_from_credential_provider(options = {}, credentials: nil, delete: []) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/aws_assume_role/profile_configuration.rb', line 53 def self.new_from_credential_provider( = {}, credentials: nil, delete: []) option_hash = .to_h config = option_hash.fetch(:config, {}).to_h hash_to_merge = option_hash.merge config hash_to_merge.merge(credentials: credentials) if credentials delete.each do |k| hash_to_merge.delete k end hash = merge_mfa_variable(hash_to_merge) logger.debug "new_from_credential_provider with #{hash}" new hash end |
.new_from_credential_provider_initialization(options) ⇒ Object
48 49 50 51 |
# File 'lib/aws_assume_role/profile_configuration.rb', line 48 def self.new_from_credential_provider_initialization() logger.debug "new_from_credential_provider_initialization with #{options.to_h}" new_from_credential_provider(, credentials: nil, delete: []) end |
Instance Method Details
#to_h ⇒ Object
66 67 68 |
# File 'lib/aws_assume_role/profile_configuration.rb', line 66 def to_h instance_values.delete("__options__").symbolize_keys end |