-
Notifications
You must be signed in to change notification settings - Fork 174
ROX-13722: Move NodeInventory into Node #3757
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,6 +112,9 @@ func convertAndDedupRHELComponents(rc *database.RHELv2Components) []*storage.Nod | |
| } | ||
|
|
||
| func convertExecutables(exe []*scannerV1.Executable) []*storage.NodeInventory_Components_RHELComponent_Executable { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure to use getters here to avoid nils |
||
| if exe == nil { | ||
| return nil | ||
| } | ||
| arr := make([]*storage.NodeInventory_Components_RHELComponent_Executable, len(exe)) | ||
| for i, executable := range exe { | ||
| arr[i] = &storage.NodeInventory_Components_RHELComponent_Executable{ | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
This prevents potential panic if
fetchedNodeis nil.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.
Good catch, thanks.
I suppose an alternative is to have
s.Require().NotNil(fetchedNode)two lines above, but I prefer this variant.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.
For me to understand:
s.NotNil()will not stop execution of the test when the subject is nil, correct?Uh oh!
There was an error while loading. Please reload this page.
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.
Correct,
NotNilwill do the assertion, print a message and then continue. The continuation in this case would lead to a panic.It is not so bad as this is only a test code that would panic, but in this case it was an clear bug.