Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update manifest API endpoints #9969

Merged
merged 1 commit into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/api/handlers/libpod/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand Down
5 changes: 4 additions & 1 deletion test/apiv2/rest_api/test_rest_v2_0_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,13 @@ def test_pod_start_conflict(self):
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()