-
Notifications
You must be signed in to change notification settings - Fork 82
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
refactor(RHINENG-5484): refactor operating_system filter #2141
base: master
Are you sure you want to change the base?
refactor(RHINENG-5484): refactor operating_system filter #2141
Conversation
e870dce
to
fde51a7
Compare
I added some commits I was not supposed to, I'm fixing it |
fde51a7
to
4f60130
Compare
for os_name in filter_param.keys(): # this doesn't account for "os_name" instead of os names | ||
if os_name not in (os_names := _get_valid_os_names()): |
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'd recommend checking for the key "name" between these 2 lines and doing the custom logic there:
for os_name in filter_param.keys(): # this doesn't account for "os_name" instead of os names | |
if os_name not in (os_names := _get_valid_os_names()): | |
for os_name in filter_param.keys(): | |
if os_name == "name": | |
# Return an OsComparison object that implies all hosts with a matching OS name. | |
# Maybe if OsComparison.comparator is "eq" or "neq" and the major version is None? | |
elif os_name not in (os_names := _get_valid_os_names()): |
@@ -158,6 +169,7 @@ def build_operating_system_filter(filter_param: dict) -> tuple: | |||
os_filter_list.append(os_field.astext.operate(comparator, None)) | |||
|
|||
elif comparison.comparator == "eq": | |||
print("~~~~~~~~~~~~~~~~~~~``", os_field["name"].astext == comparison.name) |
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.
Around here is where you'd convert the OsComparison to an actual DB operation. If we went with the logic I posted above, this next section could be something like this:
print("~~~~~~~~~~~~~~~~~~~``", os_field["name"].astext == comparison.name) | |
os_filters = [ | |
os_field["name"].astext == comparison.name, | |
] | |
if comparison.major is not None: | |
os_filters.append(os_field["major"].astext.cast(Integer) == comparison.major) | |
if comparison.minor: | |
os_filters.append(os_field["minor"].astext.cast(Integer) == comparison.minor) | |
os_filter_list.append(and_(*os_filters)) |
Of course, you'll need to handle "neq" as well :)
Overview
This PR is being created to address RHINENG-5484.
I tried a few different ways, I think I got a good one but I'm not sure how to write the actual filter
PR Checklist
Secure Coding Practices Documentation Reference
You can find documentation on this checklist here.
Secure Coding Checklist