8000 Support "allowed_values" within variable definitions by mwildehahn · Pull Request #245 · cloudtools/stacker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support "allowed_values" within variable definitions #245

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

Merged
merged 3 commits into from
Oct 17, 2016

Conversation

mwildehahn
Copy link
Contributor

No description provided.

allowed_values = var_def.get('allowed_values')
valid = validate_allowed_values(allowed_values, value)
if not valid:
raise UnallowedValue(var_name, value, allowed_values)
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we need a special exception here? Seems like a ValueError, though I guess at the point where we move to all stacker exceptions being from a base exception this might be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I was just using the UnallowedValue error to construct the message which probably isn't worth it

class UnallowedValue(Exception):
"""Exception raised when the value provided to a variable is not allowed.
"""
def __init__(self, variable, value, allowed_values, *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

This might be hard to find, since it doesn't list what blueprint it's a part of. I actually am starting to feel like we should be doing more with catching exceptions at the blueprint, plan or stack level to provide more context, rather than needing to pass that context down to each exception in order to figure out where things are breaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, a base exception that includes blueprint and some other data would be useful. I'm going to switch this to a ValueError for now and we can address this with the issue to track better exception handling

@mwildehahn mwildehahn merged commit 6fba357 into cloudtools:release-1.0 Oct 17, 2016
@mwildehahn mwildehahn deleted the variable-allowed-values branch October 17, 2016 20:52
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.

2 participants
0