Class: Knowledge::Adapters::Ssm
- Inherits:
-
Base
- Object
- Base
- Knowledge::Adapters::Ssm
- Defined in:
- lib/knowledge/adapters/ssm.rb
Overview
Description
This adapter takes some vars in your SSM parameters and set it in your project’s config.
Usage
@example:
adapter = Knowledge::Adapters::Ssm.new(params: { root_path: '/path', setter: MySetter, variables: my_vars)
adapter.run
Attributes
Instance Attribute Summary collapse
-
#raise_not_found ⇒ Object
readonly
Defines whether we should raise an error on param not found or not.
-
#root_path ⇒ Object
readonly
Root path for SSM parameters.
-
#setter ⇒ Class
readonly
The current value of setter.
-
#ssm_parameters ⇒ Object
readonly
Parameters to fetch.
-
#variables ⇒ Hash
readonly
The current value of variables.
Instance Method Summary collapse
-
#initialize(params: {}, setter:, variables:) ⇒ Ssm
constructor
A new instance of Ssm.
-
#run ⇒ Object
Runs the actual adapter.
Constructor Details
#initialize(params: {}, setter:, variables:) ⇒ Ssm
Returns a new instance of Ssm.
53 54 55 56 57 58 59 60 |
# File 'lib/knowledge/adapters/ssm.rb', line 53 def initialize(params: {}, setter:, variables:) super @client = params[:client] || params['client'] @raise_not_found = params[:raise_on_parameter_not_found] || params['raise_on_parameter_not_found'] || false @root_path = params[:root_path] || params['root_path'] @ssm_parameters = @root_path ? fetch_recursive_parameters : fetch_parameters end |
Instance Attribute Details
#raise_not_found ⇒ Object (readonly)
Defines whether we should raise an error on param not found or not
31 32 33 |
# File 'lib/knowledge/adapters/ssm.rb', line 31 def raise_not_found @raise_not_found end |
#root_path ⇒ Object (readonly)
Root path for SSM parameters
31 32 33 |
# File 'lib/knowledge/adapters/ssm.rb', line 31 def root_path @root_path end |
#setter ⇒ Class (readonly)
Returns the current value of setter.
31 32 33 |
# File 'lib/knowledge/adapters/ssm.rb', line 31 def setter @setter end |
#ssm_parameters ⇒ Object (readonly)
Parameters to fetch
31 32 33 |
# File 'lib/knowledge/adapters/ssm.rb', line 31 def ssm_parameters @ssm_parameters end |
#variables ⇒ Hash (readonly)
Returns the current value of variables.
31 32 33 |
# File 'lib/knowledge/adapters/ssm.rb', line 31 def variables @variables end |
Instance Method Details
#run ⇒ Object
Runs the actual adapter.
67 68 69 70 71 72 73 74 |
# File 'lib/knowledge/adapters/ssm.rb', line 67 def run variables.each do |name, (path, default_value)| path = "/#{path.sub('/', '')}" value = Array(@ssm_parameters).detect { |p| p.name == "#{base_path}#{path}" }&.value setter.set(name: name, value: extract_value(value, default_value)) end end |