Skip to content

Commit

Permalink
refactor resolve_parameters loop
Browse files Browse the repository at this point in the history
Now values will always split on commas, eliminating one of the nested
conditionals.

Also changed 2 of the `if`s to `elif`s; probably won't make any
performance impact, but since each condition is independent it feels
more precise to me.
  • Loading branch information
troyready committed Aug 20, 2016
1 parent bbbe8c4 commit ab86f6d
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions stacker/actions/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,34 +83,34 @@ def resolve_parameters(parameters, blueprint, context, provider):
blueprint.name, k)
continue
value = v
if isinstance(value, basestring) and "::" in value:
# Get from the Output(s) of another stack(s) in the stack_map
v_list = []
# v_list holds each value in the (potentially) comma-delimited list of
# values for each parameter
v_list = []
if isinstance(value, basestring):
values = value.split(",")
for v in values:
else:
values = [value]
for v in values:
if isinstance(v, basestring) and "::" in v:
# Get from the Output(s) of another stack(s) in the stack_map
v = v.strip()
# Skip parameters not referencing another stack
if '::' not in v:
v_list.append(v)
continue
stack_name, output = v.split("::")
stack_fqn = context.get_fqn(stack_name)
try:
v_list.append(
provider.get_output(stack_fqn, output))
except KeyError:
raise exceptions.OutputDoesNotExist(stack_fqn, v)
value = ",".join(v_list)
if value is None:
logger.debug("Got None value for parameter %s, not submitting it "
"to cloudformation, default value should be used.",
k)
continue
if isinstance(value, bool):
logger.debug("Converting parameter %s boolean \"%s\" to string.",
k, value)
value = str(value).lower()
params[k] = value
elif value is None:
logger.debug("Got None value for parameter %s, not submitting "
"it to cloudformation, default value should be "
"used.", k)
continue
elif isinstance(value, bool):
logger.debug("Converting parameter %s boolean \"%s\" to "
"string.", k, value)
v_list.append(str(value).lower())
params[k] = ",".join(v_list)
return params


Expand Down

0 comments on commit ab86f6d

Please sign in to comment.