-
-
Notifications
You must be signed in to change notification settings - Fork 184
feat: Add support for removing fields from diff #1200
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
Conversation
nolar
left a comment
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.
Thanks for the contribution! The functionality might be helpful indeed. But it is better to use the existing routines to manage the dicts and fields uniformly with the rest of the framework.
Signed-off-by: f.medini <[email protected]>
Signed-off-by: f.medini <[email protected]>
Signed-off-by: f.medini <[email protected]>
Signed-off-by: f.medini <[email protected]>
Signed-off-by: f.medini <[email protected]>
Signed-off-by: f.medini <[email protected]>
Signed-off-by: Sergey Vasilyev <[email protected]>
| 'i': 'j', | ||
| } | ||
| }) | ||
| storage = cls(ignored_fields=['a.b', 'a.e.f.g', 'h', 'k.l.m']) |
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.
Just for the record: a.e.f.g is not a field, only a.e.f is β so it is an extra test for the removal of a non-existent field, the same as k.l.m.
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.
Yes a.e.f.g is technically not a field, but this one in particular causes dicts.remove to throw a TypeError exception because a.e.f is a field but does not support item deletion, hence the extra test.
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.
Got it. Makes sense, indeed.
|
|
||
| def __init__(self, ignored_fields: Iterable[dicts.FieldSpec] | None = None) -> None: | ||
| super().__init__() | ||
| self.ignored_fields = list(ignored_fields or []) # materialize the iterable |
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.
Note: I've added this materialization here, so that depletable iterables would persist and be reusable across multiple runs. I hope nobody uses generators (both expressions & functions) in this context, but just in case.
|
Released as 1.39.1. Thanks for the contribution! |
related: #1087
This PR solves this comment from the previously mentioned issue.
trivy-dojo-report-operator's
VulnerabilityReportresources can get very big and cause issues. Having the ability to remove a couple of fields from the diff solves it.Acknowledgement: Thanks to @baracoder for suggesting the core idea behind this approach!