-
Notifications
You must be signed in to change notification settings - Fork 88
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
#21 Verify optional/mandatory fields #25
Conversation
Should be merged into develop instead of master (changed) |
prom2teams/message/parser.py
Outdated
@@ -6,19 +6,28 @@ | |||
|
|||
|
|||
def parse(json_str): | |||
logger.debug('received: %s', json_str) | |||
|
|||
return_dict = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
including type information (dict) in a variable name is considered an antipattern:
prom2teams/message/parser.py
Outdated
'alert_description': json_alerts_annotations_attr['description'], | ||
'alert_status': json_alerts_attr['status'] | ||
} | ||
mandatory_fields = ['alertname', 'status', 'instance', 'summary'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be extracted to a new def? (check_mandatory_fields ¿?)
prom2teams/message/parser.py
Outdated
|
||
for field in fields: | ||
if field in json_alerts_attr: | ||
return_dict['alert_'+field] = json_alerts_attr[field] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'alert_'+field should be extracted to a variable before the conditional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it's good idea to add a test for check_fields
function
Agree. Working on it. |
…prom2teams into features/optional_json_fields
Done. Check the changes out @jdvr @dortegau @jmonterrubio |
alertname
toalert_alertname
(to make it easier to loop over it).