Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #468 from 01org/sameo/topic/storage
Browse files Browse the repository at this point in the history
ciao-image: Fix service UploadImage
  • Loading branch information
Samuel Ortiz authored Aug 16, 2016
2 parents 005b6d1 + aae1567 commit 2abcb88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 10 additions & 2 deletions ciao-image/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 2 additions & 6 deletions openstack/image/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 2abcb88

Please sign in to comment.