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:
Andrei Aaron
2025-03-13 10:06:02 +02:00
committed by GitHub
parent d87cdc9840
commit 2a4edde637
99 changed files with 169 additions and 149 deletions
+4 -3
View File
@@ -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
+20 -1
View File
@@ -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)
})
})
}