Merge pull request #166 from mrunalp/image_no_nil

Make image APIs return empty struct instead of nil
This commit is contained in:
Antonio Murdaca 2016-10-21 08:10:09 +02:00 committed by GitHub
commit 5290ca593a

View file

@ -6,6 +6,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/Sirupsen/logrus"
"github.com/containers/image/directory" "github.com/containers/image/directory"
"github.com/containers/image/image" "github.com/containers/image/image"
"github.com/containers/image/transports" "github.com/containers/image/transports"
@ -15,22 +16,25 @@ import (
// ListImages lists existing images. // ListImages lists existing images.
func (s *Server) ListImages(ctx context.Context, req *pb.ListImagesRequest) (*pb.ListImagesResponse, error) { func (s *Server) ListImages(ctx context.Context, req *pb.ListImagesRequest) (*pb.ListImagesResponse, error) {
logrus.Debugf("ListImages: %+v", req)
// TODO // TODO
// containers/storage will take care of this by looking inside /var/lib/ocid/images // containers/storage will take care of this by looking inside /var/lib/ocid/images
// and listing images. // and listing images.
return nil, nil return &pb.ListImagesResponse{}, nil
} }
// ImageStatus returns the status of the image. // ImageStatus returns the status of the image.
func (s *Server) ImageStatus(ctx context.Context, req *pb.ImageStatusRequest) (*pb.ImageStatusResponse, error) { func (s *Server) ImageStatus(ctx context.Context, req *pb.ImageStatusRequest) (*pb.ImageStatusResponse, error) {
logrus.Debugf("ImageStatus: %+v", req)
// TODO // TODO
// containers/storage will take care of this by looking inside /var/lib/ocid/images // containers/storage will take care of this by looking inside /var/lib/ocid/images
// and getting the image status // and getting the image status
return nil, nil return &pb.ImageStatusResponse{}, nil
} }
// PullImage pulls a image with authentication config. // PullImage pulls a image with authentication config.
func (s *Server) PullImage(ctx context.Context, req *pb.PullImageRequest) (*pb.PullImageResponse, error) { func (s *Server) PullImage(ctx context.Context, req *pb.PullImageRequest) (*pb.PullImageResponse, error) {
logrus.Debugf("PullImage: %+v", req)
img := req.GetImage().GetImage() img := req.GetImage().GetImage()
if img == "" { if img == "" {
return nil, errors.New("got empty imagespec name") return nil, errors.New("got empty imagespec name")
@ -97,5 +101,6 @@ func (s *Server) PullImage(ctx context.Context, req *pb.PullImageRequest) (*pb.P
// RemoveImage removes the image. // RemoveImage removes the image.
func (s *Server) RemoveImage(ctx context.Context, req *pb.RemoveImageRequest) (*pb.RemoveImageResponse, error) { func (s *Server) RemoveImage(ctx context.Context, req *pb.RemoveImageRequest) (*pb.RemoveImageResponse, error) {
return nil, nil logrus.Debugf("RemoveImage: %+v", req)
return &pb.RemoveImageResponse{}, nil
} }