-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: de-duplicate same dpkg
packages with different filePaths from different layers
#8298
fix: de-duplicate same dpkg
packages with different filePaths from different layers
#8298
Conversation
dpkg
packages with different filePaths from different layers
pkg/fanal/applier/docker.go
Outdated
packages := lo.UniqBy(mergedLayer.Packages, func(pkg ftypes.Package) string { | ||
return cmp.Or(pkg.ID, fmt.Sprintf("%s@%s", pkg.Name, utils.FormatVersion(pkg))) | ||
}) | ||
mergedLayer.Packages = lo.Ternary(len(packages) > 0, packages, 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.
Since this conversion is needed in many places, we may want to define a utility function somewhere, like:
func NilIfEmpty[T any](s []T) []T {
if len(s) == 0 {
return nil
}
return s
}
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 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.
Oh, we already have it 😄
Description
See #8297
Related issues
Checklist