copy/copy.go
func (c *copier) copyConfig(ctx context.Context, src types.Image) error {
	srcInfo := src.ConfigInfo()
	if srcInfo.Digest != "" {
		configBlob, err := src.ConfigBlob(ctx)
		if err != nil {
			return errors.Wrapf(err, "Error reading config blob %s", srcInfo.Digest)
		}

		destInfo, err := func() (types.BlobInfo, error) { // A scope for defer
			progressPool, progressCleanup := c.newProgressPool(ctx)
			defer progressCleanup()
			bar := c.createProgressBar(progressPool, srcInfo, "config", "done")
			destInfo, err := c.copyBlobFromStream(ctx, bytes.NewReader(configBlob), srcInfo, nil, false, true, bar)
			if err != nil {
				return types.BlobInfo{}, err
			}
			bar.SetTotal(int64(len(configBlob)), true)
			return destInfo, nil
		}()
		if err != nil {
			return nil
		}
		if destInfo.Digest != srcInfo.Digest {
			return errors.Errorf("Internal error: copying uncompressed config blob %s changed digest to %s", srcInfo.Digest, destInfo.Digest)
		}
	}
	return nil
}
func (c *copier) copyConfig(ctx context.Context, src types.Image) error {
	srcInfo := src.ConfigInfo()
	if srcInfo.Digest != "" {
		configBlob, err := src.ConfigBlob(ctx)
		if err != nil {
			return errors.Wrapf(err, "Error reading config blob %s", srcInfo.Digest)
		}

		destInfo, err := func() (types.BlobInfo, error) { // A scope for defer
			progressPool, progressCleanup := c.newProgressPool(ctx)
			defer progressCleanup()
			bar := c.createProgressBar(progressPool, srcInfo, "config", "done")
			destInfo, err := c.copyBlobFromStream(ctx, bytes.NewReader(configBlob), srcInfo, nil, false, true, bar)
			if err != nil {
				return types.BlobInfo{}, err
			}
			bar.SetTotal(int64(len(configBlob)), true)
			return destInfo, nil
		}()
		if err != nil {
			return nil
		}
		if destInfo.Digest != srcInfo.Digest {
			return errors.Errorf("Internal error: copying uncompressed config blob %s changed digest to %s", srcInfo.Digest, destInfo.Digest)
		}
	}
	return nil
}
func ( c * copier ) copyConfig ( ctx context . Context , src types . Image ) error { srcInfo := src . ConfigInfo ( ) if srcInfo . Digest != " " { configBlob , err := src . ConfigBlob ( ctx ) if err != nil { return errors . Wrapf ( err , " " , srcInfo . Digest ) } destInfo , err := func ( ) ( types . BlobInfo , error ) { // A scope for defer progressPool , progressCleanup := c . newProgressPool ( ctx ) defer progressCleanup ( ) bar := c . createProgressBar ( progressPool , srcInfo , " " , " " ) destInfo , err := c . copyBlobFromStream ( ctx , bytes . NewReader ( configBlob ) , srcInfo , nil , false , true , bar ) if err != nil { return types . BlobInfo { } , err } bar . SetTotal ( int64 ( len ( configBlob ) ) , true ) return destInfo , nil } ( ) if err != nil { return nil } if destInfo . Digest != srcInfo . Digest { return errors . Errorf ( " " , srcInfo . Digest , destInfo . Digest ) } } return nil }
// copyConfig copies config.json, if any, from src to dest.
copyConfig copies config . json if any from src to dest .