Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apis/server/image_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,15 @@ func (s *Server) saveImage(ctx context.Context, rw http.ResponseWriter, req *htt

return nil
}

// getImageHistory gets image history.
func (s *Server) getImageHistory(ctx context.Context, rw http.ResponseWriter, req *http.Request) error {
imageName := mux.Vars(req)["name"]

history, err := s.ImageMgr.ImageHistory(ctx, imageName)
if err != nil {
return err
}

return EncodeResponse(rw, http.StatusOK, history)
}
1 change: 1 addition & 0 deletions apis/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func initRoute(s *Server) http.Handler {
s.addRoute(r, http.MethodPost, "/images/{name:.*}/tag", s.postImageTag)
s.addRoute(r, http.MethodPost, "/images/load", withCancelHandler(s.loadImage))
s.addRoute(r, http.MethodGet, "/images/save", withCancelHandler(s.saveImage))
s.addRoute(r, http.MethodGet, "/images/{name:.*}/history", s.getImageHistory)

// volume
s.addRoute(r, http.MethodGet, "/volumes", s.listVolume)
Expand Down
59 changes: 58 additions & 1 deletion apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ paths:

/images/{imageid}/json:
get:
summary: "Inspect a image"
summary: "Inspect an image"
description: "Return the information about image"
operationId: "ImageInspect"
produces:
Expand Down Expand Up @@ -273,6 +273,27 @@ paths:
parameters:
- $ref: "#/parameters/imageid"

/images/{imageid}/history:
get:
summary: "Get an image's history"
description: "Return the history of each layer of image"
operationId: "ImageHistory"
produces:
- "application/json"
responses:
200:
description: "no error"
schema:
type: "array"
items:
$ref: "#/definitions/HistoryResultItem"
404:
$ref: "#/responses/404ErrorResponse"
500:
$ref: "#/responses/500ErrorResponse"
parameters:
- $ref: "#/parameters/imageid"

/images/json:
get:
summary: "List Images"
Expand Down Expand Up @@ -2927,6 +2948,42 @@ definitions:
description: "the base layer content hash."
type: "string"

HistoryResultItem:
description: "An object containing image history at API side."
type: "object"
required: [ID, Created, CreatedBy, Author, Comment, EmptyLayer, Size]
properties:
ID:
description: "ID of each layer image."
type: "string"
x-nullable: false
Created:
description: "the combined date and time at which the layer was created."
type: "integer"
format: "int64"
x-nullable: false
CreatedBy:
description: "the command which created the layer."
type: "string"
x-nullable: false
Author:
description: "the author of the build point."
type: "string"
x-nullable: false
Comment:
description: "a custom message set when creating the layer."
type: "string"
x-nullable: false
EmptyLayer:
description: "mark whether the history item created a filesystem diff or not."
type: "boolean"
x-nullable: false
Size:
description: "size of each layer image."
type: "integer"
format: "int64"
x-nullable: false

SearchResultItem:
type: "object"
description: "search result item in search results."
Expand Down
173 changes: 173 additions & 0 deletions apis/types/history_result_item.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading