summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2021-04-09 11:00:06 -0700
committerJhon Honce <jhonce@redhat.com>2021-04-09 11:00:06 -0700
commitd41c33eb91e6890de80826eba98dcc80e9e1994a (patch)
tree1ab2f6078c5cc7581f9ef9a3593bd74e650edccf /pkg/api/handlers/libpod
parent54dce001cce131bbbdcf16512a4722e080561fc7 (diff)
downloadpodman-d41c33eb91e6890de80826eba98dcc80e9e1994a.tar.gz
podman-d41c33eb91e6890de80826eba98dcc80e9e1994a.tar.bz2
podman-d41c33eb91e6890de80826eba98dcc80e9e1994a.zip
Update manifest API endpoints
* Add validation for manifest name * Always return an array for manifests even if empty * Add missing return in df handler when returning error. Caused an additional null to be written to client crashing python decoder. When c/image is refactored to include manifests, manifest endpoints should be revisited. Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r--pkg/api/handlers/libpod/manifests.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/api/handlers/libpod/manifests.go b/pkg/api/handlers/libpod/manifests.go
index 5ababc36b..6a491ae48 100644
--- a/pkg/api/handlers/libpod/manifests.go
+++ b/pkg/api/handlers/libpod/manifests.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"net/http"
+ "github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/manifest"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v3/libpod"
@@ -34,6 +35,16 @@ func ManifestCreate(w http.ResponseWriter, r *http.Request) {
errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
+
+ // TODO: (jhonce) When c/image is refactored the roadmap calls for this check to be pushed into that library.
+ for _, n := range query.Name {
+ if _, err := reference.ParseNormalizedNamed(n); err != nil {
+ utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
+ errors.Wrapf(err, "invalid image name %s", n))
+ return
+ }
+ }
+
rtc, err := runtime.GetConfig()
if err != nil {
utils.InternalServerError(w, err)
@@ -75,11 +86,16 @@ func ManifestInspect(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusNotFound, inspectError)
return
}
+
var list manifest.Schema2List
if err := json.Unmarshal(inspectReport, &list); err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Unmarshal()"))
return
}
+ if list.Manifests == nil {
+ list.Manifests = make([]manifest.Schema2ManifestDescriptor, 0)
+ }
+
utils.WriteResponse(w, http.StatusOK, &list)
}