f3b7065bd8
The image's canonical reference is a name with a digest of the image's manifest, so in imageService.ImageStatus() and imageService.ListImages(), divide the image's name list into tagged and digested values, and if we have names, add canonical versions. In Server.ContainerStatus(), return the image name as it was given to us as the image, and the image digested reference as the image reference. In Server.ListImages(), be sure to only return tagged names in the RepoTags field. In Server.ImageStatus(), also return canonical references in the RepoDigests field. In Server.PullImage(), be sure that we consistently return the same image reference for an image, whether we ended up pulling it or not. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package server
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"golang.org/x/net/context"
|
|
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
|
)
|
|
|
|
// ListImages lists existing images.
|
|
func (s *Server) ListImages(ctx context.Context, req *pb.ListImagesRequest) (resp *pb.ListImagesResponse, err error) {
|
|
const operation = "list_images"
|
|
defer func() {
|
|
recordOperation(operation, time.Now())
|
|
recordError(operation, err)
|
|
}()
|
|
|
|
logrus.Debugf("ListImagesRequest: %+v", req)
|
|
filter := ""
|
|
reqFilter := req.GetFilter()
|
|
if reqFilter != nil {
|
|
filterImage := reqFilter.GetImage()
|
|
if filterImage != nil {
|
|
filter = filterImage.Image
|
|
}
|
|
}
|
|
results, err := s.StorageImageServer().ListImages(s.ImageContext(), filter)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resp = &pb.ListImagesResponse{}
|
|
for _, result := range results {
|
|
if result.Size != nil {
|
|
resp.Images = append(resp.Images, &pb.Image{
|
|
Id: result.ID,
|
|
RepoTags: result.RepoTags,
|
|
RepoDigests: result.RepoDigests,
|
|
Size_: *result.Size,
|
|
})
|
|
} else {
|
|
resp.Images = append(resp.Images, &pb.Image{
|
|
Id: result.ID,
|
|
RepoTags: result.RepoTags,
|
|
RepoDigests: result.RepoDigests,
|
|
})
|
|
}
|
|
}
|
|
logrus.Debugf("ListImagesResponse: %+v", resp)
|
|
return resp, nil
|
|
}
|