From aae1567e6c4b668c8b9e0f171cc89fbb1ee01341 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Wed, 17 Aug 2016 01:44:53 +0200 Subject: [PATCH] ciao-image: Fix service UploadImage It was left empty. Signed-off-by: Samuel Ortiz --- ciao-image/service/service.go | 12 ++++++++++-- openstack/image/api.go | 8 ++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ciao-image/service/service.go b/ciao-image/service/service.go index 2cd41ec95..45cfdd1da 100644 --- a/ciao-image/service/service.go +++ b/ciao-image/service/service.go @@ -102,8 +102,16 @@ func (is ImageService) ListImages() ([]image.CreateImageResponse, error) { } // UploadImage will upload a raw image data and update its status. -func (is ImageService) UploadImage(imageID string, body io.Reader) error { - return nil +func (is ImageService) UploadImage(imageID string, body io.Reader) (image.UploadImageResponse, error) { + var response image.UploadImageResponse + + err := is.ds.UploadImage(imageID, body) + if err != nil { + return response, err + } + + response.ImageID = imageID + return response, nil } // Config is required to setup the API context for the image service. diff --git a/openstack/image/api.go b/openstack/image/api.go index 754cc9a68..b029e093c 100644 --- a/openstack/image/api.go +++ b/openstack/image/api.go @@ -201,7 +201,7 @@ type APIConfig struct { // information needed to implement the image endpoints. type Service interface { CreateImage(CreateImageRequest) (CreateImageResponse, error) - UploadImage(imageID string, body io.Reader) error + UploadImage(string, io.Reader) (UploadImageResponse, error) ListImages() ([]CreateImageResponse, error) } @@ -339,15 +339,11 @@ func uploadImage(context *Context, w http.ResponseWriter, r *http.Request) (APIR defer r.Body.Close() - err := context.UploadImage(imageID, r.Body) + resp, err := context.UploadImage(imageID, r.Body) if err != nil { return errorResponse(err), err } - resp := UploadImageResponse{ - ImageID: imageID, - } - return APIResponse{http.StatusOK, resp}, nil }