mirror of
https://github.com/project-zot/zot.git
synced 2025-01-06 22:40:28 -05:00
manifest can be deleted only by digest and not tag
Fixes issue #67. As per dist spec, DELETE of a image manifest can only be done with digest as <reference> param. Previously, tags were being allowed as well. This is not conformant to the spec.
This commit is contained in:
parent
8d04f97f17
commit
faad2b1d1f
3 changed files with 14 additions and 1 deletions
|
@ -467,9 +467,13 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) {
|
||||||
So(resp.StatusCode(), ShouldEqual, 200)
|
So(resp.StatusCode(), ShouldEqual, 200)
|
||||||
So(resp.Body(), ShouldNotBeEmpty)
|
So(resp.Body(), ShouldNotBeEmpty)
|
||||||
|
|
||||||
// delete manifest
|
// delete manifest by tag should fail
|
||||||
resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/test:1.0")
|
resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/test:1.0")
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
So(resp.StatusCode(), ShouldEqual, 404)
|
||||||
|
// delete manifest by digest
|
||||||
|
resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/" + digest.String())
|
||||||
|
So(err, ShouldBeNil)
|
||||||
So(resp.StatusCode(), ShouldEqual, 202)
|
So(resp.StatusCode(), ShouldEqual, 202)
|
||||||
// delete again should fail
|
// delete again should fail
|
||||||
resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/" + digest.String())
|
resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/" + digest.String())
|
||||||
|
|
|
@ -443,6 +443,12 @@ func (is *ImageStore) DeleteImageManifest(repo string, reference string) error {
|
||||||
return errors.ErrRepoNotFound
|
return errors.ErrRepoNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err := godigest.Parse(reference)
|
||||||
|
if err != nil {
|
||||||
|
is.log.Error().Err(err).Msg("invalid reference")
|
||||||
|
return errors.ErrManifestNotFound
|
||||||
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadFile(path.Join(dir, "index.json"))
|
buf, err := ioutil.ReadFile(path.Join(dir, "index.json"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -115,6 +115,9 @@ func TestAPIs(t *testing.T) {
|
||||||
_, _, _, err = il.GetImageManifest("test", d.String())
|
_, _, _, err = il.GetImageManifest("test", d.String())
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
|
err = il.DeleteImageManifest("test", "1.0")
|
||||||
|
So(err, ShouldNotBeNil)
|
||||||
|
|
||||||
err = il.DeleteImageManifest("test", d.String())
|
err = il.DeleteImageManifest("test", d.String())
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue