2016-11-22 23:05:37 +01:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2016-10-18 10:48:33 -04:00
|
|
|
"fmt"
|
|
|
|
|
2016-11-22 23:05:37 +01:00
|
|
|
"github.com/Sirupsen/logrus"
|
2017-05-17 19:18:35 +02:00
|
|
|
"github.com/containers/storage"
|
2016-11-22 23:05:37 +01:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ImageStatus returns the status of the image.
|
|
|
|
func (s *Server) ImageStatus(ctx context.Context, req *pb.ImageStatusRequest) (*pb.ImageStatusResponse, error) {
|
2016-10-18 10:48:33 -04:00
|
|
|
logrus.Debugf("ImageStatusRequest: %+v", req)
|
|
|
|
image := ""
|
|
|
|
img := req.GetImage()
|
|
|
|
if img != nil {
|
2017-02-03 15:41:28 +01:00
|
|
|
image = img.Image
|
2016-10-18 10:48:33 -04:00
|
|
|
}
|
|
|
|
if image == "" {
|
|
|
|
return nil, fmt.Errorf("no image specified")
|
|
|
|
}
|
2017-07-17 08:25:32 -04:00
|
|
|
status, err := s.StorageImageServer().ImageStatus(s.ImageContext(), image)
|
2016-10-18 10:48:33 -04:00
|
|
|
if err != nil {
|
2016-12-21 21:54:15 +01:00
|
|
|
if err == storage.ErrImageUnknown {
|
|
|
|
return &pb.ImageStatusResponse{}, nil
|
|
|
|
}
|
2016-10-18 10:48:33 -04:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
resp := &pb.ImageStatusResponse{
|
|
|
|
Image: &pb.Image{
|
2017-02-03 15:41:28 +01:00
|
|
|
Id: status.ID,
|
2016-10-18 10:48:33 -04:00
|
|
|
RepoTags: status.Names,
|
2017-02-03 15:41:28 +01:00
|
|
|
Size_: *status.Size,
|
2017-05-20 17:08:00 +02:00
|
|
|
// TODO: https://github.com/kubernetes-incubator/cri-o/issues/531
|
2016-10-18 10:48:33 -04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
logrus.Debugf("ImageStatusResponse: %+v", resp)
|
|
|
|
return resp, nil
|
2016-11-22 23:05:37 +01:00
|
|
|
}
|