mirror of https://github.com/containers/image.git
Allow for disabling schema1 MIME types for docker destinations
This commit adds DockerDisableDestSchema1MIMETypes to types.Context which, if set to true, will omit DockerV2Schema1SignedMediaType and DockerV2Schema1MediaType from dockerImageDestination.SupportedManifestMIMETypes. The motivation for this is that newer versions of the docker registry (2.7.1 and later) disable schema1 by default. If a user attempts to copy a v2schema1 image into the newer registry, the result is a 500 error. With this change, when calling copy.Image(), setting options.DestinationCtx.DockerDisableDestSchema1MIMETypes to true will allow copying of a schema1 image to a destination registry with schema1 disabled. The image will be converted to schema2. Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
parent
c2b21451a1
commit
c9356f778f
|
|
@ -58,14 +58,16 @@ func (d *dockerImageDestination) Close() error {
|
|||
}
|
||||
|
||||
func (d *dockerImageDestination) SupportedManifestMIMETypes() []string {
|
||||
return []string{
|
||||
mimeTypes := []string{
|
||||
imgspecv1.MediaTypeImageManifest,
|
||||
manifest.DockerV2Schema2MediaType,
|
||||
imgspecv1.MediaTypeImageIndex,
|
||||
manifest.DockerV2ListMediaType,
|
||||
manifest.DockerV2Schema1SignedMediaType,
|
||||
manifest.DockerV2Schema1MediaType,
|
||||
}
|
||||
if d.c.sys == nil || !d.c.sys.DockerDisableDestSchema1MIMETypes {
|
||||
mimeTypes = append(mimeTypes, manifest.DockerV2Schema1SignedMediaType, manifest.DockerV2Schema1MediaType)
|
||||
}
|
||||
return mimeTypes
|
||||
}
|
||||
|
||||
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
|
||||
|
|
|
|||
|
|
@ -547,6 +547,8 @@ type SystemContext struct {
|
|||
// Note that this field is used mainly to integrate containers/image into projectatomic/docker
|
||||
// in order to not break any existing docker's integration tests.
|
||||
DockerDisableV1Ping bool
|
||||
// If true, dockerImageDestination.SupportedManifestMIMETypes will omit the Schema1 media types from the supported list
|
||||
DockerDisableDestSchema1MIMETypes bool
|
||||
// Directory to use for OSTree temporary files
|
||||
OSTreeTmpDirPath string
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue