mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 12:28:01 +08:00
gc: fix test cases since umoci GC is more strict
umoci GC enforces a valid index.json and current tests were a little lax.
This commit is contained in:
@@ -15,9 +15,9 @@ import (
|
||||
"github.com/anuvu/zot/errors"
|
||||
zlog "github.com/anuvu/zot/pkg/log"
|
||||
guuid "github.com/gofrs/uuid"
|
||||
"github.com/openSUSE/umoci"
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/openSUSE/umoci"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
@@ -335,6 +335,11 @@ func (is *ImageStore) PutImageManifest(repo string, reference string, mediaType
|
||||
return "", errors.ErrBadManifest
|
||||
}
|
||||
|
||||
if m.SchemaVersion != 2 {
|
||||
is.log.Error().Int("SchemaVersion", m.SchemaVersion).Msg("invalid manifest")
|
||||
return "", errors.ErrBadManifest
|
||||
}
|
||||
|
||||
for _, l := range m.Layers {
|
||||
digest := l.Digest
|
||||
blobPath := is.BlobPath(repo, digest)
|
||||
|
||||
@@ -105,6 +105,7 @@ func TestAPIs(t *testing.T) {
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
m := ispec.Manifest{}
|
||||
m.SchemaVersion = 2
|
||||
mb, _ := json.Marshal(m)
|
||||
|
||||
Convey("Bad image manifest", func() {
|
||||
@@ -116,7 +117,20 @@ func TestAPIs(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Good image manifest", func() {
|
||||
m := ispec.Manifest{Layers: []ispec.Descriptor{{Digest: d}}}
|
||||
m := ispec.Manifest{
|
||||
Config: ispec.Descriptor{
|
||||
Digest: d,
|
||||
Size: int64(l),
|
||||
},
|
||||
Layers: []ispec.Descriptor{
|
||||
{
|
||||
MediaType: "application/vnd.oci.image.layer.v1.tar",
|
||||
Digest: d,
|
||||
Size: int64(l),
|
||||
},
|
||||
},
|
||||
}
|
||||
m.SchemaVersion = 2
|
||||
mb, _ = json.Marshal(m)
|
||||
d := godigest.FromBytes(mb)
|
||||
_, err = il.PutImageManifest("test", d.String(), ispec.MediaTypeImageManifest, mb)
|
||||
|
||||
Reference in New Issue
Block a user