mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
Fix latest for "image list" command
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/image/v5/docker/reference"
|
"github.com/containers/image/v5/docker/reference"
|
||||||
"github.com/crazy-max/diun/v4/pb"
|
"github.com/crazy-max/diun/v4/pb"
|
||||||
|
"github.com/crazy-max/diun/v4/pkg/registry"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
@@ -17,16 +18,18 @@ func (c *Client) ImageList(ctx context.Context, request *pb.ImageListRequest) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ilr []*pb.ImageListResponse_Image
|
var ilr []*pb.ImageListResponse_Image
|
||||||
for name, manifests := range images {
|
for name, mfsts := range images {
|
||||||
latest := &manifests[0]
|
mfsts := mfsts
|
||||||
for _, manifest := range manifests {
|
var latest *registry.Manifest
|
||||||
if manifest.Created.After(*latest.Created) {
|
for _, mfst := range mfsts {
|
||||||
latest = &manifest
|
mfst := mfst
|
||||||
|
if latest == nil || mfst.Created.After(*latest.Created) {
|
||||||
|
latest = &mfst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ilr = append(ilr, &pb.ImageListResponse_Image{
|
ilr = append(ilr, &pb.ImageListResponse_Image{
|
||||||
Name: name,
|
Name: name,
|
||||||
ManifestsCount: int64(len(manifests)),
|
ManifestsCount: int64(len(mfsts)),
|
||||||
Latest: &pb.Manifest{
|
Latest: &pb.Manifest{
|
||||||
Tag: latest.Tag,
|
Tag: latest.Tag,
|
||||||
MimeType: latest.MIMEType,
|
MimeType: latest.MIMEType,
|
||||||
|
|||||||
Reference in New Issue
Block a user