Skip to content

Commit d99f47e

Browse files
committed
feature: add pouch history functionality
Signed-off-by: xiechengsheng <[email protected]>
1 parent 33d90d2 commit d99f47e

File tree

13 files changed

+624
-3
lines changed

13 files changed

+624
-3
lines changed

apis/server/image_bridge.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,15 @@ func (s *Server) saveImage(ctx context.Context, rw http.ResponseWriter, req *htt
172172

173173
return nil
174174
}
175+
176+
// getImageHistory gets image history.
177+
func (s *Server) getImageHistory(ctx context.Context, rw http.ResponseWriter, req *http.Request) error {
178+
imageName := mux.Vars(req)["name"]
179+
180+
history, err := s.ImageMgr.ImageHistory(ctx, imageName)
181+
if err != nil {
182+
return err
183+
}
184+
185+
return EncodeResponse(rw, http.StatusOK, history)
186+
}

apis/server/router.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func initRoute(s *Server) http.Handler {
6767
s.addRoute(r, http.MethodPost, "/images/{name:.*}/tag", s.postImageTag)
6868
s.addRoute(r, http.MethodPost, "/images/load", withCancelHandler(s.loadImage))
6969
s.addRoute(r, http.MethodGet, "/images/save", withCancelHandler(s.saveImage))
70+
s.addRoute(r, http.MethodGet, "/images/{name:.*}/history", s.getImageHistory)
7071

7172
// volume
7273
s.addRoute(r, http.MethodGet, "/volumes", s.listVolume)

apis/swagger.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ paths:
197197

198198
/images/{imageid}/json:
199199
get:
200-
summary: "Inspect a image"
200+
summary: "Inspect an image"
201201
description: "Return the information about image"
202202
operationId: "ImageInspect"
203203
produces:
@@ -227,6 +227,27 @@ paths:
227227
parameters:
228228
- $ref: "#/parameters/imageid"
229229

230+
/images/{imageid}/history:
231+
get:
232+
summary: "Get an image's history"
233+
description: "Return the parent layers about image"
234+
operationId: "ImageHistory"
235+
produces:
236+
- "application/json"
237+
responses:
238+
200:
239+
description: "no error"
240+
schema:
241+
type: "array"
242+
items:
243+
$ref: "#/definitions/HistoryResultItem"
244+
404:
245+
$ref: "#/responses/404ErrorResponse"
246+
500:
247+
$ref: "#/responses/500ErrorResponse"
248+
parameters:
249+
- $ref: "#/parameters/imageid"
250+
230251
/images/json:
231252
get:
232253
summary: "List Images"
@@ -2800,6 +2821,42 @@ definitions:
28002821
description: "the base layer content hash."
28012822
type: "string"
28022823

2824+
HistoryResultItem:
2825+
description: "An object containing image history at API side."
2826+
type: "object"
2827+
required: [ID, Created, CreatedBy, Author, Comment, EmptyLayer, Size]
2828+
properties:
2829+
ID:
2830+
description: "ID of every layer image."
2831+
type: "string"
2832+
x-nullable: false
2833+
Created:
2834+
description: "the combined date and time at which the layer was created."
2835+
type: "integer"
2836+
format: "int64"
2837+
x-nullable: false
2838+
CreatedBy:
2839+
description: "the command which created the layer."
2840+
type: "string"
2841+
x-nullable: false
2842+
Author:
2843+
description: "the author of the build point."
2844+
type: "string"
2845+
x-nullable: false
2846+
Comment:
2847+
description: "a custom message set when creating the layer."
2848+
type: "string"
2849+
x-nullable: false
2850+
EmptyLayer:
2851+
description: "mark whether the history item created a filesystem diff or not."
2852+
type: "boolean"
2853+
x-nullable: false
2854+
Size:
2855+
description: "size of every layer image."
2856+
type: "integer"
2857+
format: "int64"
2858+
x-nullable: false
2859+
28032860
SearchResultItem:
28042861
type: "object"
28052862
description: "search result item in search results."

apis/types/history_result_item.go

Lines changed: 173 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)