2016-11-22 22:05:37 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2016-10-18 14:48:33 +00:00
|
|
|
"fmt"
|
|
|
|
|
2016-11-22 22:05:37 +00:00
|
|
|
"github.com/Sirupsen/logrus"
|
2016-12-21 20:54:15 +00:00
|
|
|
"github.com/containers/storage/storage"
|
2016-11-22 22:05:37 +00: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 14:48:33 +00:00
|
|
|
logrus.Debugf("ImageStatusRequest: %+v", req)
|
|
|
|
image := ""
|
|
|
|
img := req.GetImage()
|
|
|
|
if img != nil {
|
|
|
|
image = img.GetImage()
|
|
|
|
}
|
|
|
|
if image == "" {
|
|
|
|
return nil, fmt.Errorf("no image specified")
|
|
|
|
}
|
|
|
|
status, err := s.images.ImageStatus(s.imageContext, image)
|
|
|
|
if err != nil {
|
2016-12-21 20:54:15 +00:00
|
|
|
if err == storage.ErrImageUnknown {
|
|
|
|
return &pb.ImageStatusResponse{}, nil
|
|
|
|
}
|
2016-10-18 14:48:33 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
resp := &pb.ImageStatusResponse{
|
|
|
|
Image: &pb.Image{
|
|
|
|
Id: &status.ID,
|
|
|
|
RepoTags: status.Names,
|
|
|
|
Size_: status.Size,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
logrus.Debugf("ImageStatusResponse: %+v", resp)
|
|
|
|
return resp, nil
|
2016-11-22 22:05:37 +00:00
|
|
|
}
|