diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-12 16:17:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 16:17:22 +0200 |
commit | bd3dcb9ec4d4b2d722e25a9d001c63474e54dd53 (patch) | |
tree | 848323c6b2eee2a998f48febdf2c398f15243ea0 | |
parent | 0ac73f25eb45611324f255b5222863b6ff0e8525 (diff) | |
parent | d41c33eb91e6890de80826eba98dcc80e9e1994a (diff) | |
download | podman-bd3dcb9ec4d4b2d722e25a9d001c63474e54dd53.tar.gz podman-bd3dcb9ec4d4b2d722e25a9d001c63474e54dd53.tar.bz2 podman-bd3dcb9ec4d4b2d722e25a9d001c63474e54dd53.zip |
Merge pull request #9969 from jwhonce/wip/manifests
Update manifest API endpoints
-rw-r--r-- | pkg/api/handlers/libpod/manifests.go | 16 | ||||
-rw-r--r-- | test/apiv2/rest_api/test_rest_v2_0_0.py | 5 |
2 files changed, 20 insertions, 1 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) } diff --git a/test/apiv2/rest_api/test_rest_v2_0_0.py b/test/apiv2/rest_api/test_rest_v2_0_0.py index e3874c182..97336cb71 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -727,10 +727,13 @@ class TestApi(unittest.TestCase): start = json.loads(r.text) self.assertGreater(len(start["Errs"]), 0, r.text) + def test_manifest_409(self): + r = requests.post(_url("/manifests/create"), params={"name": "ThisIsAnInvalidImage"}) + self.assertEqual(r.status_code, 400, r.text) + def test_df(self): r = requests.get(_url("/system/df")) self.assertEqual(r.status_code, 200, r.text) - if __name__ == "__main__": unittest.main() |