Skip to content

Fix expand parameters bug in util to support any parameters#6

Merged
vishrutshah merged 4 commits intomonitor-clifrom
monitor-feedbacks
Mar 13, 2017
Merged

Fix expand parameters bug in util to support any parameters#6
vishrutshah merged 4 commits intomonitor-clifrom
monitor-feedbacks

Conversation

@vishrutshah
Copy link
Owner

Adding --filters into activity-logs & tenant-activity-logs
Adding --ids support into alert-rules & autoscale-settings' show and delete commands

@troydai @tjprescott @derekbekoe Please review the PR when you get a chance. Thanks!

Adding --filters into activity-logs & tenant-activity-logs
Adding --ids support into alert-rules & autoscale-settings' show and delete commands
# pylint: disable=too-many-arguments
def list_activity_logs(client, correlation_id=None, resource_group=None, resource_id=None,
resource_provider=None, start_time=None, end_time=None,
# pylint: disable=too-many-arguments, line-too-long
Copy link

Choose a reason for hiding this comment

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

The line-too-long is for which line. Can we overcome it?

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's coming from line 132
if len([x for x in [correlation_id, resource_group, resource_id, resource_provider] if x]) > 1:
if i split it i think it'd be not readable.

Or i can create local list for [correlation_id, resource_group, resource_id, resource_provider] to decrease characters on line 132

Copy link

Choose a reason for hiding this comment

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

I saw this pattern been adopted in multiple places. Why not extract it into a method? like

def single(collection):
    return len([x for x in collection if x]) > 1

Copy link
Owner Author

Choose a reason for hiding this comment

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

sounds great. Updated it.

type=json.loads,
help='JSON encoded condition configuration. Use @{file} to load from a file.')

for command in ['show', 'delete']:
Copy link

Choose a reason for hiding this comment

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

I don't appreciate this form of registering command parameters, and it is the very form of registering I was trying to avoid when designing these patterns. The problem with using a loop to register parameters for multiple commands is sacrificing maintainability, readability for merely limited reusability benefits. It makes it difficult to locate where are the parameter registrations are. It requires extra effort when a future change is going to make to only one of the command. It breaks the pattern that parameters associating to one command are cluster together under one indented context. I would advise against this form of parameter registering and prefer duplication.

Choose a reason for hiding this comment

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

On the other hand... I am for it 😸

Copy link
Owner Author

Choose a reason for hiding this comment

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

hahah... Let me split it for simplicity.

Copy link

@derekbekoe derekbekoe left a comment

Choose a reason for hiding this comment

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

LGTM

@vishrutshah vishrutshah merged commit d9b44ca into monitor-cli Mar 13, 2017
@vishrutshah vishrutshah deleted the monitor-feedbacks branch March 13, 2017 20:47
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