-
Notifications
You must be signed in to change notification settings - Fork 21
feat: adding CLEAN_KEYS support #869
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
Changes from 8 commits
b723588
e89d4a0
de77186
c40b214
513243e
c63f9ec
9e32c23
25036d0
8f214c8
9eb9245
b7b6a27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
| """ | ||
| Provides props.conf parsing mechanism | ||
| """ | ||
| from typing import Dict | ||
| from typing import Dict, List | ||
| from typing import Generator | ||
| from typing import Optional | ||
| import logging | ||
|
|
@@ -57,6 +57,14 @@ def props(self) -> Optional[Dict]: | |
| self._props = self._conf_parser.item_dict() | ||
| return self._props if self._props else None | ||
|
|
||
| def update_field_names(self, field_list) -> List: | ||
| """ | ||
| update field names to remove all the non-alphanumeric chars and replace them with _ | ||
| """ | ||
| for index in range(len(field_list)): | ||
|
||
| field_list[index].name = re.sub(r"\W+", "_", field_list[index].name) | ||
| return field_list | ||
|
|
||
| def get_props_fields(self): | ||
| """ | ||
| Parse the props.conf and yield all supported fields | ||
|
|
@@ -82,6 +90,13 @@ def get_props_fields(self): | |
| else: | ||
| for transform_stanza, fields in self._get_report_fields(key, value): | ||
| field_list = list(fields) | ||
| if ( | ||
| self.transforms_parser.transforms.get( | ||
| transform_stanza, {} | ||
| ).get("CLEAN_KEYS") | ||
| != "false" | ||
| ): | ||
| field_list = self.update_field_names(field_list) | ||
| if field_list: | ||
| yield { | ||
| "stanza": stanza_name, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,23 @@ SOURCE_KEY = event_id | |
| DELIMS = "=" | ||
| FIELDS = server_contact_mode, dest | ||
|
|
||
| # Component tested: REPORT, DELIM-FIELDS-SOURCE_KEY | ||
| # Scenario:# Similar to the above scenario | ||
| ## ## server-contact-mode should be searched as server_contact_mode as CLEAN_KEYS = true by default | ||
|
||
| [fiction-tsc-sk-delim-format-with-clean-keys] | ||
| CLEAN_KEYS = false | ||
| SOURCE_KEY = event_id | ||
| DELIMS = "=" | ||
| FIELDS = server-contact-mode, dest | ||
|
|
||
| # Component tested: REPORT, DELIM | ||
| # Scenario: | ||
| ## server-contact-mode should be searched as server_contact_mode as CLEAN_KEYS = true by default[fiction-tsc-non-alphanumeric] | ||
| [fiction-tsc-non-alphanumeric] | ||
| DELIMS = " " | ||
| FIELDS = server-contact, dest_1 | ||
|
|
||
|
|
||
| # Component tested: REPORT, REGEX-FORMAT-SOURCE_KEY | ||
| # Scenario: Source-key with regex and format | ||
| ## An individual search for SOURCE_KEY and each field extracted in FORMAT and a single search of all the fields with SOURCE_KEY. | ||
|
|
||
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.
Can you please type
field_listhere and specify the return type as well?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.
Done