Skip to content

Commit

Permalink
alter compat no such image message
Browse files Browse the repository at this point in the history
we need to alter the return error message when a GET (inspect) is performed on an image using the compatibility layer.  docker-py bindings look for a initial capped error message.

Signed-off-by: baude <[email protected]>
  • Loading branch information
baude committed Oct 13, 2020
1 parent 7ad631b commit ef5c884
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/api/handlers/compat/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ func GetImage(w http.ResponseWriter, r *http.Request) {
name := utils.GetName(r)
newImage, err := utils.GetImage(r, name)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusNotFound, errors.Wrapf(err, "failed to find image %s", name))
// Here we need to fiddle with the error message because docker-py is looking for "No
// such image" to determine on how to raise the correct exception.
errMsg := strings.ReplaceAll(err.Error(), "no such image", "No such image")
utils.Error(w, "Something went wrong.", http.StatusNotFound, errors.Errorf("failed to find image %s: %s", name, errMsg))
return
}
inspect, err := handlers.ImageDataToImageInspect(r.Context(), newImage)
Expand Down

0 comments on commit ef5c884

Please sign in to comment.