diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-07 21:49:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 21:49:24 +0200 |
commit | 11c8b01e1d81008bc55fed8d6f62ce39dc5459c8 (patch) | |
tree | 36f7089418825a179b5e667a2324ba0cf39f57d0 /pkg/api | |
parent | 08fa3d511f2b96613bbbe76e517f2c9288e5bf56 (diff) | |
parent | 8ae28a55acc51a02597b23140916a690fbbdc3fc (diff) | |
download | podman-11c8b01e1d81008bc55fed8d6f62ce39dc5459c8.tar.gz podman-11c8b01e1d81008bc55fed8d6f62ce39dc5459c8.tar.bz2 podman-11c8b01e1d81008bc55fed8d6f62ce39dc5459c8.zip |
Merge pull request #5739 from jwhonce/wip/diff
V2 Podman diff(changes) support
Diffstat (limited to 'pkg/api')
-rw-r--r-- | pkg/api/handlers/compat/changes.go | 20 | ||||
-rw-r--r-- | pkg/api/handlers/compat/swagger.go | 10 | ||||
-rw-r--r-- | pkg/api/server/register_containers.go | 35 | ||||
-rw-r--r-- | pkg/api/server/register_images.go | 31 |
4 files changed, 96 insertions, 0 deletions
diff --git a/pkg/api/handlers/compat/changes.go b/pkg/api/handlers/compat/changes.go new file mode 100644 index 000000000..6907c487e --- /dev/null +++ b/pkg/api/handlers/compat/changes.go @@ -0,0 +1,20 @@ +package compat + +import ( + "net/http" + + "github.com/containers/libpod/libpod" + "github.com/containers/libpod/pkg/api/handlers/utils" +) + +func Changes(w http.ResponseWriter, r *http.Request) { + runtime := r.Context().Value("runtime").(*libpod.Runtime) + + id := utils.GetName(r) + changes, err := runtime.GetDiff("", id) + if err != nil { + utils.InternalServerError(w, err) + return + } + utils.WriteJSON(w, 200, changes) +} diff --git a/pkg/api/handlers/compat/swagger.go b/pkg/api/handlers/compat/swagger.go index cbd8e61fb..f1aabf987 100644 --- a/pkg/api/handlers/compat/swagger.go +++ b/pkg/api/handlers/compat/swagger.go @@ -2,6 +2,7 @@ package compat import ( "github.com/containers/libpod/pkg/api/handlers/utils" + "github.com/containers/storage/pkg/archive" ) // Create container @@ -25,3 +26,12 @@ type swagCtrWaitResponse struct { } } } + +// Object Changes +// swagger:response Changes +type swagChangesResponse struct { + // in:body + Body struct { + Changes []archive.Change + } +} diff --git a/pkg/api/server/register_containers.go b/pkg/api/server/register_containers.go index f126112d0..150cca872 100644 --- a/pkg/api/server/register_containers.go +++ b/pkg/api/server/register_containers.go @@ -1377,5 +1377,40 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/restore"), s.APIHandler(libpod.Restore)).Methods(http.MethodPost) + + // swagger:operation GET /containers/{name}/changes libpod libpodChangesContainer + // swagger:operation GET /libpod/containers/{name}/changes compat changesContainer + // --- + // tags: + // - containers + // - containers (compat) + // summary: Report on changes to container's filesystem; adds, deletes or modifications. + // description: | + // Returns which files in a container's filesystem have been added, deleted, or modified. The Kind of modification can be one of: + // + // 0: Modified + // 1: Added + // 2: Deleted + // parameters: + // - in: path + // name: name + // type: string + // required: true + // description: the name or id of the container + // responses: + // 200: + // description: Array of Changes + // content: + // application/json: + // schema: + // $ref: "#/responses/Changes" + // 404: + // $ref: "#/responses/NoSuchContainer" + // 500: + // $ref: "#/responses/InternalError" + r.HandleFunc(VersionedPath("/containers/{name}/changes"), s.APIHandler(compat.Changes)) + r.HandleFunc("/containers/{name}/changes", s.APIHandler(compat.Changes)) + r.HandleFunc(VersionedPath("/libpod/containers/{name}/changes"), s.APIHandler(compat.Changes)) + return nil } diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index d45423096..77560e789 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -1125,5 +1125,36 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/untag"), s.APIHandler(libpod.UntagImage)).Methods(http.MethodPost) + + // swagger:operation GET /libpod/images/{name}/changes libpod libpodChangesImages + // --- + // tags: + // - images + // summary: Report on changes to images's filesystem; adds, deletes or modifications. + // description: | + // Returns which files in a images's filesystem have been added, deleted, or modified. The Kind of modification can be one of: + // + // 0: Modified + // 1: Added + // 2: Deleted + // parameters: + // - in: path + // name: name + // type: string + // required: true + // description: the name or id of the container + // responses: + // 200: + // description: Array of Changes + // content: + // application/json: + // schema: + // $ref: "#/responses/Changes" + // 404: + // $ref: "#/responses/NoSuchContainer" + // 500: + // $ref: "#/responses/InternalError" + r.HandleFunc(VersionedPath("/libpod/images/{name}/changes"), s.APIHandler(compat.Changes)) + return nil } |