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

{Monitor}Bug fix for stop iteration #12800

Merged
merged 3 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ def autoscale_rule_create(cmd, client, autoscale_name, resource_group_name, cond

def autoscale_rule_list(cmd, client, autoscale_name, resource_group_name, profile_name=DEFAULT_PROFILE_NAME):
autoscale_settings = client.get(resource_group_name, autoscale_name)
profile_names = [x.name for x in autoscale_settings.profiles]
if profile_name not in profile_names:
from knack.util import CLIError
raise CLIError('Profile name is invalid. Please check the existence of the profile.')
profile = next(x for x in autoscale_settings.profiles if x.name == profile_name)
Copy link
Contributor

@haroldrandom haroldrandom Mar 31, 2020

Choose a reason for hiding this comment

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

Another alternative is to use try...except sinppet to catch StopIteration error, then raise CLIError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well. So next cannot handle such scenario and we need extra logic. Right? Compared to try..except, I prefer current one.

Copy link
Contributor

Choose a reason for hiding this comment

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

using try..except is the same what you did now.

index = 0
# we artificially add indices to the rules so the user can target them with the remove command
Expand Down
Loading