mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
chore: update image and dist specs to v1.1.1 (#3023)
chore: update image-spec and dist-spec to v1.1.1 As side effect the warnings mentioned in https://github.com/project-zot/zui/issues/475#issuecomment-2715802363 should no longer show up. Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/opencontainers/image-spec/schema"
|
||||
imeta "github.com/opencontainers/image-spec/specs-go"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/santhosh-tekuri/jsonschema/v5"
|
||||
|
||||
zerr "zotregistry.dev/zot/errors"
|
||||
zcommon "zotregistry.dev/zot/pkg/common"
|
||||
@@ -30,7 +31,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
manifestWithEmptyLayersErrMsg = "layers: Array must have at least 1 items"
|
||||
manifestWithEmptyLayersErrMsg = "layers/minItems: minimum 1 items required, but found 0 items"
|
||||
cosignSignatureTagSuffix = "sig"
|
||||
)
|
||||
|
||||
@@ -848,9 +849,9 @@ func ValidateImageIndexSchema(buf []byte) error {
|
||||
}
|
||||
|
||||
func IsEmptyLayersError(err error) bool {
|
||||
var validationErr schema.ValidationError
|
||||
var validationErr *jsonschema.ValidationError
|
||||
if errors.As(err, &validationErr) {
|
||||
if len(validationErr.Errs) == 1 && strings.Contains(err.Error(), manifestWithEmptyLayersErrMsg) {
|
||||
if len(validationErr.Causes) == 1 && strings.Contains(err.Error(), manifestWithEmptyLayersErrMsg) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestValidateManifest(t *testing.T) {
|
||||
|
||||
So(errors.As(err, &internalErr), ShouldBeTrue)
|
||||
So(internalErr.GetDetails(), ShouldContainKey, "jsonSchemaValidation")
|
||||
So(internalErr.GetDetails()["jsonSchemaValidation"], ShouldEqual, "[schemaVersion: Must be less than or equal to 2]")
|
||||
So(internalErr.GetDetails()["jsonSchemaValidation"], ShouldContainSubstring, "must be <= 2 but found 999")
|
||||
})
|
||||
|
||||
Convey("bad config blob", func() {
|
||||
@@ -165,6 +165,25 @@ func TestValidateManifest(t *testing.T) {
|
||||
_, _, err = imgStore.PutImageManifest("test", "1.0", ispec.MediaTypeImageManifest, body)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
Convey("manifest with empty layers should not error", func() {
|
||||
manifest := ispec.Manifest{
|
||||
Config: ispec.Descriptor{
|
||||
MediaType: ispec.MediaTypeImageConfig,
|
||||
Digest: cdigest,
|
||||
Size: int64(len(cblob)),
|
||||
},
|
||||
Layers: []ispec.Descriptor{},
|
||||
}
|
||||
|
||||
manifest.SchemaVersion = 2
|
||||
|
||||
body, err := json.Marshal(manifest)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
_, _, err = imgStore.PutImageManifest("test", "1.0", ispec.MediaTypeImageManifest, body)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user