0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-01-06 22:40:28 -05:00

Merge pull request #68 from rchincha/issue-67

manifest can be deleted only by digest and not tag
This commit is contained in:
Ramkumar Chinchani 2020-01-28 16:39:52 -08:00 committed by GitHub
commit 8803c5f99b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -467,9 +467,13 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) {
So(resp.StatusCode(), ShouldEqual, 200)
So(resp.Body(), ShouldNotBeEmpty)
// delete manifest
// delete manifest by tag should fail
resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/test:1.0")
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)
// delete again should fail
resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/" + digest.String())

View file

@ -443,6 +443,12 @@ func (is *ImageStore) DeleteImageManifest(repo string, reference string) error {
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"))
if err != nil {

View file

@ -115,6 +115,9 @@ func TestAPIs(t *testing.T) {
_, _, _, err = il.GetImageManifest("test", d.String())
So(err, ShouldBeNil)
err = il.DeleteImageManifest("test", "1.0")
So(err, ShouldNotBeNil)
err = il.DeleteImageManifest("test", d.String())
So(err, ShouldBeNil)