Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support mixed parameters referencing / not referencing other stacks #183

Closed
wants to merge 2 commits into from

Conversation

troyready
Copy link
Contributor

Currently parameters can reference multiple outputs in other stacks:

SomeParameter: stack1::Output1,stack2::Output2

This commit allows parameter lists to also include variables not
referencing another stack, e.g.:

SomeParameter: ${ThingInEnvFile},stack1::Output1

I considered updating the documentation in Using Outputs as Parameters, but I'm not sure how to change the last part ("You can also pull multiple...") to note the functionality. Maybe a new section? Maybe the new functionality doesn't need to be called out?

@@ -89,6 +89,10 @@ def resolve_parameters(parameters, blueprint, context, provider):
values = value.split(",")
for v in values:
v = v.strip()
# Skip parameters not referencing another stack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like this logic is in the wrong place - honestly because the original logic was in the wrong place. We should probably pull the for loop that iterates over each part of the Parameter outside of the logic that checks for ::. SOmething like:

v_list = []
values = value.split(",")
for v in values:
  ... handle regular values, output reference values, etc ...

does that make sense? It'd make it easier, later, to add other special values other than just the :: values as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wonder if the whole logic of how we parse the values should be pulled out into it's own function, so we don't have to update it in two places like you had to here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Consolidating that would probably pave the way for the work that's being proposed in #184.

@troyready
Copy link
Contributor Author

@phobologic good thoughts, I agree. I've added another commit to rework the logic accordingly.

I tried to take a stab at consolidating the methods in the 2 files, but gave up for now -- since one of them is only checking for requirements and the other is actually getting stack outputs, I wasn't sure the best way to do it. Open to doing more on it depending on your thoughts.

Also, the circleci test is still failing but it doesn't look like it's due to this PR?

@phobologic
Copy link
Member

Hey @troyready, can you try merging master? It's been a while, and there have been fixing changes that might be included in master already that could clear up the Circle errors. So far the code looks good though, I wouldn't owrry about consolidating the methods, I agree with your assessment there.

Thanks!

@troyready troyready force-pushed the multi_param_types branch 2 times, most recently from 053caf1 to 99d810d Compare August 22, 2016 19:59
@troyready
Copy link
Contributor Author

@phobologic thanks for the tip -- I didn't realize it had fallen so behind. I've squashed and rebased it, and everything is looking green now.

@troyready troyready force-pushed the multi_param_types branch 2 times, most recently from 4e8a036 to 90e6c3b Compare August 23, 2016 13:12
@troyready
Copy link
Contributor Author

@phobologic my cleanup yesterday had introduced a breaking change, sorry about that. I've cleaned that up now and added a test to cover it.

v_list.append(str(v).lower())
else:
v_list.append(v)
if v_list != []:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get rid of this if statement - if the list is empty, there will be nothing to join, and it'll result in a blank string. Only updating the param if the list is populated is a change from the old behavior, and I'm not sure what issues it might cause.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phobologic I think the if does match the old behavior, specifically the way Nones have been handled here.

If a value is always returned, then it trips test_resolve_parameters_none_conversion.

Currently parameters can reference multiple outputs in other stacks:
```
SomeParameter: stack1::Output1,stack2::Output2
```

This commit allows parameter lists to also include variables not
referencing another stack, e.g.:
```
SomeParameter: ${ThingInEnvFile},stack1::Output1
```

Behind the scenese, 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.
@troyready
Copy link
Contributor Author

Commented more specifically on the line comment, but as a broad update just wanted to note that I've rebased on top of master and this should be merge-able now. I can squash the 2nd commit with the new test into a single commit if that'd be better.

@mwildehahn
Copy link
Contributor

Hey @troyready, I think the new lookups Variables and Lookups code (#194) we implemented should resolve your issue without this PR.

The new variables section will support:

SomeParameter: ${env_value},${stack1::Output1}

Let me know if that isn't true, closing this for now.

@mwildehahn mwildehahn closed this Aug 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants