From 103ae23504b9fdc52e4f7d4a50798553af09bfe5 Mon Sep 17 00:00:00 2001 From: Fabio Falci Date: Thu, 3 Jul 2014 10:58:13 +0100 Subject: [PATCH] Fix getImagesJSON output for api less than 1.7 Tag can be a number, like centos:6.4, and so must be handled like a string otherwise will lose quotation marks when converting to json and the client (API < 1.7) will try to convert to int, failing because the type is string. Additionally using ParseRepositoryTag to parse repository names to split the tag because an URL can have : and so more than one occurrence of : can be found on repository names. Docker-DCO-1.1-Signed-off-by: Fabio Falci (github: fabiofalci) --- api/server/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/server/server.go b/api/server/server.go index 9f88d1ad7..9e1d9f584 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -238,10 +238,10 @@ func getImagesJSON(eng *engine.Engine, version version.Version, w http.ResponseW outsLegacy := engine.NewTable("Created", 0) for _, out := range outs.Data { for _, repoTag := range out.GetList("RepoTags") { - parts := strings.Split(repoTag, ":") + repo, tag := utils.ParseRepositoryTag(repoTag) outLegacy := &engine.Env{} - outLegacy.Set("Repository", parts[0]) - outLegacy.Set("Tag", parts[1]) + outLegacy.Set("Repository", repo) + outLegacy.SetJson("Tag", tag) outLegacy.Set("Id", out.Get("Id")) outLegacy.SetInt64("Created", out.GetInt64("Created")) outLegacy.SetInt64("Size", out.GetInt64("Size"))