-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for docker images (#2714)
* 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 <[email protected]> * Signed-off-by: Ramkumar Chinchani <[email protected]> * test: add more docker compat tests Signed-off-by: Ramkumar Chinchani <[email protected]> * feat: add additional validation checks for non-OCI images Signed-off-by: Ramkumar Chinchani <[email protected]> * ci: make "full" images docker-compatible Signed-off-by: Ramkumar Chinchani <[email protected]> --------- Signed-off-by: Ramkumar Chinchani <[email protected]>
- Loading branch information
Showing
44 changed files
with
436 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"distSpecVersion": "1.1.0", | ||
"storage": { | ||
"rootDirectory": "/tmp/zot" | ||
}, | ||
"http": { | ||
"address": "127.0.0.1", | ||
"port": "8080", | ||
"compat": ["docker2s2"] | ||
}, | ||
"log": { | ||
"level": "debug" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.