Class: StackMaster::ParameterResolvers::Secret
- Inherits:
-
Resolver
- Object
- Resolver
- StackMaster::ParameterResolvers::Secret
- Defined in:
- lib/stack_master/parameter_resolvers/secret.rb
Constant Summary collapse
- SecretNotFound =
Class.new(StandardError)
Instance Method Summary collapse
-
#initialize(config, stack_definition) ⇒ Secret
constructor
A new instance of Secret.
- #resolve(value) ⇒ Object
Constructor Details
#initialize(config, stack_definition) ⇒ Secret
Returns a new instance of Secret.
14 15 16 17 |
# File 'lib/stack_master/parameter_resolvers/secret.rb', line 14 def initialize(config, stack_definition) @config = config @stack_definition = stack_definition end |
Instance Method Details
#resolve(value) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/stack_master/parameter_resolvers/secret.rb', line 19 def resolve(value) secret_key = value raise ArgumentError, "No secret_file defined for stack definition #{@stack_definition.stack_name} in #{@stack_definition.region}" unless !@stack_definition.secret_file.nil? raise ArgumentError, "Could not find secret file at #{secret_file_path}" unless File.exist?(secret_file_path) secrets_hash.fetch(secret_key) do raise SecretNotFound, "Unable to find key #{secret_key} in file #{secret_file_path}" end end |