Skip to content

Commit

Permalink
cleanup top object list logic in xray
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Quest <[email protected]>
  • Loading branch information
kcq committed Jan 1, 2025
1 parent af9f2e1 commit 617fb2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/app/master/command/xray/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,13 @@ func printImagePackage(

if len(topList) > 0 {
xc.Out.Info("layer.objects.top.start")
for _, topObject := range topList {
for toi, topObject := range topList {
if topObject == nil {
log.Errorf("layer.objects.top: skip nil topObject - layer(index=%v/id=%v/path=%s) len(%d) idx(%d)",
layer.Index, layer.ID, layer.Path, len(topList), toi)
continue
}

match := topObject.PathMatch

if !match && len(changePathMatchers) > 0 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/docker/dockerimage/topobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func (to TopObjects) Swap(i, j int) {

func (to *TopObjects) Push(x interface{}) {
item := x.(*ObjectMetadata)
if item == nil {
return
}
*to = append(*to, item)
}

Expand All @@ -42,6 +45,9 @@ func (to TopObjects) List() []*ObjectMetadata {
list := []*ObjectMetadata{}
for len(to) > 0 {
item := heap.Pop(&to).(*ObjectMetadata)
if item == nil {
continue
}
list = append([]*ObjectMetadata{item}, list...)
}

Expand Down

0 comments on commit 617fb2c

Please sign in to comment.