lib/sfn/command_module/stack.rb in sfn-3.0.22 vs lib/sfn/command_module/stack.rb in sfn-3.0.24
- old
+ new
@@ -107,21 +107,25 @@
# extract template parameters
#
# @param sparkle [SparkleFormation, Hash] template instance
# @return [Array<Array<String>, Smash>] prefix value, parameters
def prefix_parameters_setup(sparkle)
- if(sparkle.is_a?(SparkleFormation))
+ case sparkle
+ when SparkleFormation
parameter_prefix = sparkle.root? ? [] : (sparkle.root_path - [sparkle.root]).map do |s|
Bogo::Utility.camel(s.name)
end
stack_parameters = sparkle.compile.parameters
stack_parameters = stack_parameters.nil? ? Smash.new : stack_parameters._dump
- else
+ when Hash
parameter_prefix = []
stack_parameters = TEMPLATE_PARAMETER_LOCATIONS.map do |loc_key|
sparkle[loc_key]
end.compact.first || Smash.new
+ else
+ parameter_prefix = []
+ stack_parameters = Smash.new
end
[parameter_prefix, stack_parameters]
end
# Format config defined parameters to ensure expected layout
@@ -234,14 +238,15 @@
# @return [Hash]
def populate_parameters!(sparkle, opts={})
current_parameters = opts[:current_parameters] || {}
current_stack = opts[:stack]
parameter_prefix, stack_parameters = prefix_parameters_setup(sparkle)
+ sparkle_root_name = sparkle.is_a?(SparkleFormation) ? sparkle.root.name : nil
unless(stack_parameters.empty?)
format_config_parameters!
param_banner = false
stack_parameters.each do |param_name, param_value|
- ns_key = locate_config_parameter_key(parameter_prefix, param_name, sparkle.root.name)
+ ns_key = locate_config_parameter_key(parameter_prefix, param_name, sparkle_root_name)
# When parameter is a hash type, it is being set via
# intrinsic function and we don't modify
if(function_set_parameter?(current_parameters[param_name]))
if(!config[:parameters][ns_key].nil?)
ui.warn "Overriding mapped parameter value with explicit assignment `#{ns_key}`!"