func convertToSchema2(ctx context.Context, blobs distribution.BlobService, srcManifest *schema1.SignedManifest) (distribution.Manifest, error) {
	if klog.V(6).Enabled() {
		klog.Infof("Up converting v1 schema image:\n%#v", srcManifest.Manifest)
	}

	config, layers, err := ManifestToImageConfig(ctx, srcManifest, blobs, ManifestLocation{})
	if err != nil {
		return nil, err
	}
	if klog.V(6).Enabled() {
		klog.Infof("Resulting schema: %#v", config)
	}
	// create synthetic history
	// TODO: create restored history?
	if len(config.History) == 0 {
		for i := len(config.History); i < len(layers); i++ {
			config.History = append(config.History, dockerv1client.DockerConfigHistory{
				Created: config.Created,
			})
		}
	}

	configJSON, err := json.Marshal(config)
	if err != nil {
		return nil, err
	}
	if klog.V(6).Enabled() {
		klog.Infof("Resulting config.json:\n%s", string(configJSON))
	}
	b := schema2.NewManifestBuilder(blobs, schema2.MediaTypeImageConfig, configJSON)
	for _, layer := range layers {
		desc, err := blobs.Stat(ctx, layer.Digest)
		if err != nil {
			return nil, err
		}
		desc.MediaType = schema2.MediaTypeLayer
		if err := b.AppendReference(desc); err != nil {
			return nil, err
		}
	}
	return b.Build(ctx)
}
// convertToSchema2 attempts to build a v2 manifest from a v1 manifest, which requires reading blobs to get layer sizes.
// Requires the destination layers already exist in the target repository.
convertToSchema2 attempts to build a v2 manifest from a v1 manifest, which requires reading blobs to get layer sizes.
Requires the destination layers already exist in the target repository.
// convertToSchema2 attempts to build a v2 manifest from a v1 manifest which requires reading blobs to get layer sizes . // Requires the destination layers already exist in the target repository .
func convertToSchema2(ctx context.Context, blobs distribution.BlobService, srcManifest *schema1.SignedManifest) (distribution.Manifest, error) {
	if klog.V(6).Enabled() {
		klog.Infof("Up converting v1 schema image:\n%#v", srcManifest.Manifest)
	}
	config, layers, err := ManifestToImageConfig(ctx, srcManifest, blobs, ManifestLocation{})
	if err != nil {
		return nil, err
	}
	if klog.V(6).Enabled() {
		klog.Infof("Resulting schema: %#v", config)
	}
	if len(config.History) == 0 {
		for i := len(config.History); i < len(layers); i++ {
			config.History = append(config.History, dockerv1client.DockerConfigHistory{
				Created: config.Created,
			})
		}
	}
	configJSON, err := json.Marshal(config)
	if err != nil {
		return nil, err
	}
	if klog.V(6).Enabled() {
		klog.Infof("Resulting config.json:\n%s", string(configJSON))
	}
	b := schema2.NewManifestBuilder(blobs, schema2.MediaTypeImageConfig, configJSON)
	for _, layer := range layers {
		desc, err := blobs.Stat(ctx, layer.Digest)
		if err != nil {
			return nil, err
		}
		desc.MediaType = schema2.MediaTypeLayer
		if err := b.AppendReference(desc); err != nil {
			return nil, err
		}
	}
	return b.Build(ctx)
}
func convertToSchema2 ( ctx context . Context , blobs distribution . BlobService , srcManifest * schema1 . SignedManifest ) ( distribution . Manifest , error ) { if klog . V ( 6 ) . Enabled ( ) { klog . Infof ( " \n " , srcManifest . Manifest ) } config , layers , err := ManifestToImageConfig ( ctx , srcManifest , blobs , ManifestLocation { } ) if err != nil { return nil , err } if klog . V ( 6 ) . Enabled ( ) { klog . Infof ( " " , config ) } if len ( config . History ) == 0 { for i := len ( config . History ) ; i < len ( layers ) ; i ++ { config . History = append ( config . History , dockerv1client . DockerConfigHistory { Created : config . Created , } ) } } configJSON , err := json . Marshal ( config ) if err != nil { return nil , err } if klog . V ( 6 ) . Enabled ( ) { klog . Infof ( " \n " , string ( configJSON ) ) } b := schema2 . NewManifestBuilder ( blobs , schema2 . MediaTypeImageConfig , configJSON ) for _ , layer := range layers { desc , err := blobs . Stat ( ctx , layer . Digest ) if err != nil { return nil , err } desc . MediaType = schema2 . MediaTypeLayer if err := b . AppendReference ( desc ) ; err != nil { return nil , err } } return b . Build ( ctx ) }
convertToSchema2 attempts to build a v2 manifest from a v1 manifest, which requires reading blobs to get layer sizes.
convertToSchema2 attempts to build a v2 manifest from a v1 manifest which requires reading blobs to get layer sizes .
// create synthetic history // TODO: create restored history?