mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
cb2af94b0b
* feat: add support for docker images Issue #724 A new config section under "HTTP" called "Compat" is added which currently takes a list of possible compatible legacy media-types. https://github.com/opencontainers/image-spec/blob/main/media-types.md#compatibility-matrix Only "docker2s2" (Docker Manifest V2 Schema V2) is currently supported. Garbage collection also needs to be made aware of non-OCI compatible layer types. feat: add cve support for non-OCI compatible layer types Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> * Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> * test: add more docker compat tests Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> * feat: add additional validation checks for non-OCI images Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> * ci: make "full" images docker-compatible Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> --------- Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
package compat
|
|
|
|
import (
|
|
dockerList "github.com/distribution/distribution/v3/manifest/manifestlist"
|
|
docker "github.com/distribution/distribution/v3/manifest/schema2"
|
|
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
|
|
|
"zotregistry.dev/zot/errors"
|
|
)
|
|
|
|
// MediaCompatibility determines non-OCI media-compatilibility.
|
|
type MediaCompatibility string
|
|
|
|
const (
|
|
DockerManifestV2SchemaV2 = "docker2s2"
|
|
)
|
|
|
|
// docker
|
|
|
|
func CompatibleManifestMediaTypes() []string {
|
|
return []string{docker.MediaTypeManifest}
|
|
}
|
|
|
|
func IsCompatibleManifestMediaType(mediatype string) bool {
|
|
for _, mt := range CompatibleManifestMediaTypes() {
|
|
if mt == mediatype {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func CompatibleManifestListMediaTypes() []string {
|
|
return []string{dockerList.MediaTypeManifestList}
|
|
}
|
|
|
|
func IsCompatibleManifestListMediaType(mediatype string) bool {
|
|
for _, mt := range CompatibleManifestListMediaTypes() {
|
|
if mt == mediatype {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func Validate(body []byte, mediaType string) ([]v1.Descriptor, error) {
|
|
switch mediaType {
|
|
case docker.MediaTypeManifest:
|
|
var desm docker.DeserializedManifest
|
|
|
|
if err := desm.UnmarshalJSON(body); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return desm.References(), nil
|
|
case dockerList.MediaTypeManifestList:
|
|
var desm dockerList.DeserializedManifestList
|
|
|
|
if err := desm.UnmarshalJSON(body); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return desm.References(), nil
|
|
}
|
|
|
|
return nil, errors.ErrMediaTypeNotSupported
|
|
}
|