Merge pull request #2201 from containers/renovate/github.com-opencontainers-image-spec-1.x

fix(deps): update module github.com/opencontainers/image-spec to v1.1.0-rc6
This commit is contained in:
Miloslav Trmač 2024-01-18 22:53:18 +01:00 committed by GitHub
commit 695538a31a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 41 additions and 30 deletions

2
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/containers/storage v1.51.0
github.com/docker/distribution v2.8.3+incompatible
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.0-rc5
github.com/opencontainers/image-spec v1.1.0-rc6
github.com/opencontainers/image-tools v1.0.0-rc3
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0

4
go.sum
View File

@ -274,8 +274,8 @@ github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
github.com/opencontainers/image-spec v1.1.0-rc6 h1:XDqvyKsJEbRtATzkgItUqBA7QHk58yxX1Ov9HERHNqU=
github.com/opencontainers/image-spec v1.1.0-rc6/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
github.com/opencontainers/image-tools v1.0.0-rc3 h1:ZR837lBIxq6mmwEqfYrbLMuf75eBSHhccVHy6lsBeM4=
github.com/opencontainers/image-tools v1.0.0-rc3/go.mod h1:A9btVpZLzttF4iFaKNychhPyrhfOjJ1OF5KrA8GcLj4=
github.com/opencontainers/runc v1.1.10 h1:EaL5WeO9lv9wmS6SASjszOeQdSctvpbu0DdBQBizE40=

View File

@ -17,6 +17,7 @@ package schema
import (
"bufio"
"encoding/json"
"errors"
"io"
)
@ -34,7 +35,8 @@ func (e *SyntaxError) Error() string { return e.msg }
// and converts it into a *schema.SyntaxError containing line/col information using the given reader.
// If the given error is not a *json.SyntaxError it is returned unchanged.
func WrapSyntaxError(r io.Reader, err error) error {
if serr, ok := err.(*json.SyntaxError); ok {
var serr *json.SyntaxError
if errors.As(err, &serr) {
buf := bufio.NewReader(r)
line := 0
col := 0

View File

@ -17,13 +17,13 @@ package schema
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"regexp"
digest "github.com/opencontainers/go-digest"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/xeipuuv/gojsonschema"
)
@ -53,7 +53,7 @@ func (e ValidationError) Error() string {
func (v Validator) Validate(src io.Reader) error {
buf, err := io.ReadAll(src)
if err != nil {
return errors.Wrap(err, "unable to read the document file")
return fmt.Errorf("unable to read the document file: %w", err)
}
if f, ok := mapValidate[v]; ok {
@ -71,9 +71,8 @@ func (v Validator) Validate(src io.Reader) error {
result, err := gojsonschema.Validate(sl, ml)
if err != nil {
return errors.Wrapf(
WrapSyntaxError(bytes.NewReader(buf), err),
"schema %s: unable to validate", v)
return fmt.Errorf("schema %s: unable to validate: %w", v,
WrapSyntaxError(bytes.NewReader(buf), err))
}
if result.Valid() {
@ -101,12 +100,12 @@ func validateManifest(r io.Reader) error {
buf, err := io.ReadAll(r)
if err != nil {
return errors.Wrapf(err, "error reading the io stream")
return fmt.Errorf("error reading the io stream: %w", err)
}
err = json.Unmarshal(buf, &header)
if err != nil {
return errors.Wrap(err, "manifest format mismatch")
return fmt.Errorf("manifest format mismatch: %w", err)
}
if header.Config.MediaType != string(v1.MediaTypeImageConfig) {
@ -131,16 +130,16 @@ func validateDescriptor(r io.Reader) error {
buf, err := io.ReadAll(r)
if err != nil {
return errors.Wrapf(err, "error reading the io stream")
return fmt.Errorf("error reading the io stream: %w", err)
}
err = json.Unmarshal(buf, &header)
if err != nil {
return errors.Wrap(err, "descriptor format mismatch")
return fmt.Errorf("descriptor format mismatch: %w", err)
}
err = header.Digest.Validate()
if err == digest.ErrDigestUnsupported {
if errors.Is(err, digest.ErrDigestUnsupported) {
// we ignore unsupported algorithms
fmt.Printf("warning: unsupported digest: %q: %v\n", header.Digest, err)
return nil
@ -153,12 +152,12 @@ func validateIndex(r io.Reader) error {
buf, err := io.ReadAll(r)
if err != nil {
return errors.Wrapf(err, "error reading the io stream")
return fmt.Errorf("error reading the io stream: %w", err)
}
err = json.Unmarshal(buf, &header)
if err != nil {
return errors.Wrap(err, "index format mismatch")
return fmt.Errorf("index format mismatch: %w", err)
}
for _, manifest := range header.Manifests {
@ -180,12 +179,12 @@ func validateConfig(r io.Reader) error {
buf, err := io.ReadAll(r)
if err != nil {
return errors.Wrapf(err, "error reading the io stream")
return fmt.Errorf("error reading the io stream: %w", err)
}
err = json.Unmarshal(buf, &header)
if err != nil {
return errors.Wrap(err, "config format mismatch")
return fmt.Errorf("config format mismatch: %w", err)
}
checkPlatform(header.OS, header.Architecture)
@ -194,7 +193,7 @@ func validateConfig(r io.Reader) error {
envRegexp := regexp.MustCompile(`^[^=]+=.*$`)
for _, e := range header.Config.Env {
if !envRegexp.MatchString(e) {
return errors.Errorf("unexpected env: %q", e)
return fmt.Errorf("unexpected env: %q", e)
}
}

View File

@ -21,12 +21,20 @@ const (
// MediaTypeLayoutHeader specifies the media type for the oci-layout.
MediaTypeLayoutHeader = "application/vnd.oci.layout.header.v1+json"
// MediaTypeImageManifest specifies the media type for an image manifest.
MediaTypeImageManifest = "application/vnd.oci.image.manifest.v1+json"
// MediaTypeImageIndex specifies the media type for an image index.
MediaTypeImageIndex = "application/vnd.oci.image.index.v1+json"
// MediaTypeImageManifest specifies the media type for an image manifest.
MediaTypeImageManifest = "application/vnd.oci.image.manifest.v1+json"
// MediaTypeImageConfig specifies the media type for the image configuration.
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
// MediaTypeEmptyJSON specifies the media type for an unused blob containing the value "{}".
MediaTypeEmptyJSON = "application/vnd.oci.empty.v1+json"
)
const (
// MediaTypeImageLayer is the media type used for layers referenced by the manifest.
MediaTypeImageLayer = "application/vnd.oci.image.layer.v1.tar"
@ -37,7 +45,15 @@ const (
// MediaTypeImageLayerZstd is the media type used for zstd compressed
// layers referenced by the manifest.
MediaTypeImageLayerZstd = "application/vnd.oci.image.layer.v1.tar+zstd"
)
// Non-distributable layer media-types.
//
// Deprecated: Non-distributable layers are deprecated, and not recommended
// for future use. Implementations SHOULD NOT produce new non-distributable
// layers.
// https://github.com/opencontainers/image-spec/pull/965
const (
// MediaTypeImageLayerNonDistributable is the media type for layers referenced by
// the manifest but with distribution restrictions.
//
@ -66,10 +82,4 @@ const (
// layers.
// https://github.com/opencontainers/image-spec/pull/965
MediaTypeImageLayerNonDistributableZstd = "application/vnd.oci.image.layer.nondistributable.v1.tar+zstd"
// MediaTypeImageConfig specifies the media type for the image configuration.
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
// MediaTypeEmptyJSON specifies the media type for an unused blob containing the value `{}`
MediaTypeEmptyJSON = "application/vnd.oci.empty.v1+json"
)

View File

@ -25,7 +25,7 @@ const (
VersionPatch = 0
// VersionDev indicates development branch. Releases will be empty string.
VersionDev = "-rc.5"
VersionDev = "-rc.6"
)
// Version is the specification version that the package types support.

2
vendor/modules.txt vendored
View File

@ -431,7 +431,7 @@ github.com/oklog/ulid
## explicit; go 1.13
github.com/opencontainers/go-digest
github.com/opencontainers/go-digest/digestset
# github.com/opencontainers/image-spec v1.1.0-rc5
# github.com/opencontainers/image-spec v1.1.0-rc6
## explicit; go 1.18
github.com/opencontainers/image-spec/schema
github.com/opencontainers/image-spec/specs-go