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

#21 Verify optional/mandatory fields #25

Merged
merged 11 commits into from
Nov 6, 2017
Merged

Conversation

jnogol
Copy link
Collaborator

@jnogol jnogol commented Sep 14, 2017

  • Changed alertname to alert_alertname (to make it easier to loop over it).
  • Now we have two lists with the mandatory and optional fields.
  • In case one mandatory field is missing, it will send an error message to Microsoft Teams

@dortegau
Copy link
Member

dortegau commented Sep 15, 2017

Should be merged into develop instead of master (changed)

@dortegau dortegau changed the base branch from master to develop September 15, 2017 10:17
@@ -6,19 +6,28 @@


def parse(json_str):
logger.debug('received: %s', json_str)

return_dict = {}
Copy link
Member

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:

https://docs.quantifiedcode.com/python-anti-patterns/readability/putting_type_information_in_a_variable_name.html

'alert_description': json_alerts_annotations_attr['description'],
'alert_status': json_alerts_attr['status']
}
mandatory_fields = ['alertname', 'status', 'instance', 'summary']
Copy link
Member

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 ¿?)


for field in fields:
if field in json_alerts_attr:
return_dict['alert_'+field] = json_alerts_attr[field]
Copy link
Member

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

@dortegau dortegau changed the title #21 #21 Verify optional/mandatory fields Sep 25, 2017
Copy link
Contributor

@jdvr jdvr left a 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

@jnogol
Copy link
Collaborator Author

jnogol commented Nov 3, 2017

Agree. Working on it.

@jnogol
Copy link
Collaborator Author

jnogol commented Nov 3, 2017

Done. Check the changes out @jdvr @dortegau @jmonterrubio

@jdvr jdvr merged commit cb9aef2 into develop Nov 6, 2017
@jdvr jdvr deleted the features/optional_json_fields branch November 6, 2017 15:20
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.

3 participants