瀏覽代碼

api/inspect: Fix nil RepoTags and RepoDigests

Make RepoTags and RepoDigests empty arrays instead of nil.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Paweł Gronowski 2 年之前
父節點
當前提交
1be26e9f0c
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      api/server/router/image/image_routes.go

+ 8 - 0
api/server/router/image/image_routes.go

@@ -286,6 +286,14 @@ func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, er
 		comment = img.History[len(img.History)-1].Comment
 	}
 
+	// Make sure we output empty arrays instead of nil.
+	if repoTags == nil {
+		repoTags = []string{}
+	}
+	if repoDigests == nil {
+		repoDigests = []string{}
+	}
+
 	return &types.ImageInspect{
 		ID:              img.ID().String(),
 		RepoTags:        repoTags,