-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fixes #910 - Insights tab displayed for non-RHEL hosts #911
base: develop
Are you sure you want to change the base?
Fixes #910 - Insights tab displayed for non-RHEL hosts #911
Conversation
- Add helper-function isNotRhelHost - Hide insights tab based on host-OS - Hide TotalRisk card based on host-OS
|
||
export const isNotRhelHost = ({ hostDetails }) => | ||
// eslint-disable-next-line camelcase | ||
!new RegExp('red\\s?hat', 'i').test(hostDetails?.operatingsystem_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.
operatingsystem_name
is not safe as this value can be changed by the user. As this plugin depends on Katello anyways, you can use hostDetails?.operatingsystem_family
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.
Well, you will get the OS type Redhat for Alma, Rocky, etc. as well, so this is tricky... But maybe you can use it for a sanity check.
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.
There is no better check for this right now. I would just go with this solution.
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.
What about checking at least for RHEL
? I don't know how people are naming their OSes these days.
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.
on Redhat, these OS are created automatically from the imported Manifest.
Other areas will not work if OS name was changed, like https://github.com/theforeman/foreman/blob/develop/app/views/unattended/provisioning_templates/snippet/insights.erb#L10
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.
LGTM, adding the metadata field looks like a good solution to me.
Will take a look |
Fixes #910
Changes made
The isNotRhelHost check is not the nicest but this is similar to how it is done in:
provisioning_templates/snippet/insights.erb:<% if @host.operatingsystem.name == 'RedHat' -%>