From 6e6a38b4168ed7a528614f6499783243a8668395 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 22 Jan 2021 14:09:55 +0100 Subject: podman manifest exists Add podman manifest exists command with remote support. Signed-off-by: Paul Holzinger --- pkg/api/handlers/libpod/manifests.go | 18 ++++++++++++++++++ pkg/api/server/register_manifest.go | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'pkg/api') diff --git a/pkg/api/handlers/libpod/manifests.go b/pkg/api/handlers/libpod/manifests.go index dce861f6f..35221ecf1 100644 --- a/pkg/api/handlers/libpod/manifests.go +++ b/pkg/api/handlers/libpod/manifests.go @@ -48,6 +48,24 @@ func ManifestCreate(w http.ResponseWriter, r *http.Request) { utils.WriteResponse(w, http.StatusOK, handlers.IDResponse{ID: manID}) } +// ExistsManifest check if a manifest list exists +func ExistsManifest(w http.ResponseWriter, r *http.Request) { + runtime := r.Context().Value("runtime").(*libpod.Runtime) + name := utils.GetName(r) + + ic := abi.ImageEngine{Libpod: runtime} + report, err := ic.ManifestExists(r.Context(), name) + if err != nil { + utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err) + return + } + if !report.Value { + utils.Error(w, "manifest not found", http.StatusNotFound, errors.New("manifest not found")) + return + } + utils.WriteResponse(w, http.StatusNoContent, "") +} + func ManifestInspect(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) name := utils.GetName(r) diff --git a/pkg/api/server/register_manifest.go b/pkg/api/server/register_manifest.go index 5e7d94538..eefcc396e 100644 --- a/pkg/api/server/register_manifest.go +++ b/pkg/api/server/register_manifest.go @@ -38,6 +38,26 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/manifests/create"), s.APIHandler(libpod.ManifestCreate)).Methods(http.MethodPost) + // swagger:operation GET /libpod/manifests/{name}/exists manifests Exists + // --- + // summary: Exists + // description: Check if manifest list exists + // parameters: + // - in: path + // name: name + // type: string + // required: true + // description: the name of the manifest list + // produces: + // - application/json + // responses: + // 204: + // description: manifest list exists + // 404: + // $ref: '#/responses/NoSuchManifest' + // 500: + // $ref: '#/responses/InternalError' + r.Handle(VersionedPath("/libpod/manifests/{name}/exists"), s.APIHandler(libpod.ExistsManifest)).Methods(http.MethodGet) // swagger:operation GET /libpod/manifests/{name:.*}/json manifests Inspect // --- // summary: Inspect -- cgit v1.2.3-54-g00ecf