Class: Sfn::Callback::ParametersStacks

Inherits:
ParametersInfrastructure show all
Defined in:
lib/sfn-parameters/stacks.rb

Overview

Auto load stack parameters for single stack pattern

Constant Summary

Constants inherited from ParametersInfrastructure

Sfn::Callback::ParametersInfrastructure::VALID_EXTENSIONS

Instance Method Summary collapse

Methods inherited from ParametersInfrastructure

#after_config_update

Methods included from SfnParameters::Utils

#lock_content, #unlock_content

Instance Method Details

#load_file_for(stack_name) ⇒ Smash

Load the configuration file

Parameters:

  • stack_name (String)

Returns:

  • (Smash)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sfn-parameters/stacks.rb', line 12

def load_file_for(stack_name)
  root_path = config.fetch(:sfn_parameters, :directory, "stacks")
  paths = Dir.glob(File.join(root_path, "#{stack_name}{#{VALID_EXTENSIONS.join(",")}}")).map(&:to_s)
  if paths.size > 1
    raise ArgumentError.new "Multiple parameter file matches encountered! (#{paths.join(", ")})"
  elsif paths.empty?
    Smash.new
  else
    unlock_content(Bogo::Config.new(paths.first).data)
  end
end