Skip to content

Commit

Permalink
[fix] filter images panic
Browse files Browse the repository at this point in the history
Signed-off-by: xyz-li <[email protected]>
  • Loading branch information
xyz-li committed Sep 26, 2024
1 parent b2a7039 commit 5837f4a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pkg/imgutil/filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ func FilterByCreatedAt(ctx context.Context, client *containerd.Client, before []
if err != nil {
return []images.Image{}, err
}
maxTime = beforeImages[0].CreatedAt
for _, image := range beforeImages {
if image.CreatedAt.After(maxTime) {
maxTime = image.CreatedAt
if len(beforeImages) > 0 {
maxTime = beforeImages[0].CreatedAt
for _, image := range beforeImages {
if image.CreatedAt.After(maxTime) {
maxTime = image.CreatedAt
}
}
}
}
Expand All @@ -163,10 +165,12 @@ func FilterByCreatedAt(ctx context.Context, client *containerd.Client, before []
if err != nil {
return []images.Image{}, err
}
minTime = sinceImages[0].CreatedAt
for _, image := range sinceImages {
if image.CreatedAt.Before(minTime) {
minTime = image.CreatedAt
if len(sinceImages) > 0 {
minTime = sinceImages[0].CreatedAt
for _, image := range sinceImages {
if image.CreatedAt.Before(minTime) {
minTime = image.CreatedAt
}
}
}
}
Expand Down

0 comments on commit 5837f4a

Please sign in to comment.