From ef5c8846737f4c9697f34bd920718d2b1292ad49 Mon Sep 17 00:00:00 2001 From: baude Date: Tue, 13 Oct 2020 12:11:52 -0500 Subject: alter compat no such image message 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 --- pkg/api/handlers/compat/images.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index f49ce59da..3431823bd 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -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) -- cgit v1.2.3-54-g00ecf