Add a transportName parameter to docker/internal/tarfile.NewSource

This will allow using it in error messages in the future.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2022-07-02 01:45:50 +02:00
parent 301daca202
commit 6f22578367
5 changed files with 6 additions and 6 deletions

View File

@ -28,7 +28,7 @@ func newImageSource(ctx context.Context, sys *types.SystemContext, ref archiveRe
archive = a
closeArchive = true
}
src := tarfile.NewSource(archive, closeArchive, ref.ref, ref.sourceIndex)
src := tarfile.NewSource(archive, closeArchive, ref.Transport().Name(), ref.ref, ref.sourceIndex)
return &archiveImageSource{
Source: src,
ref: ref,

View File

@ -39,7 +39,7 @@ func newImageSource(ctx context.Context, sys *types.SystemContext, ref daemonRef
if err != nil {
return nil, err
}
src := tarfile.NewSource(archive, true, nil, -1)
src := tarfile.NewSource(archive, true, ref.Transport().Name(), nil, -1)
return &daemonImageSource{
ref: ref,
Source: src,

View File

@ -48,7 +48,7 @@ type layerInfo struct {
// NewSource returns a tarfile.Source for an image in the specified archive matching ref
// and sourceIndex (or the only image if they are (nil, -1)).
// The archive will be closed if closeArchive
func NewSource(archive *Reader, closeArchive bool, ref reference.NamedTagged, sourceIndex int) *Source {
func NewSource(archive *Reader, closeArchive bool, transportName string, ref reference.NamedTagged, sourceIndex int) *Source {
return &Source{
archive: archive,
closeArchive: closeArchive,

View File

@ -47,7 +47,7 @@ func TestSourcePrepareLayerData(t *testing.T) {
reader, err := NewReaderFromStream(nil, &tarfileBuffer)
require.NoError(t, err, c.config)
src := NewSource(reader, true, nil, -1)
src := NewSource(reader, true, "transport name", nil, -1)
require.NoError(t, err, c.config)
defer src.Close()
configStream, _, err := src.GetBlob(ctx, types.BlobInfo{

View File

@ -28,7 +28,7 @@ func NewSourceFromFileWithContext(sys *types.SystemContext, path string) (*Sourc
if err != nil {
return nil, err
}
src := internal.NewSource(archive, true, nil, -1)
src := internal.NewSource(archive, true, "[An external docker/tarfile caller]", nil, -1)
return &Source{internal: src}, nil
}
@ -49,7 +49,7 @@ func NewSourceFromStreamWithSystemContext(sys *types.SystemContext, inputStream
if err != nil {
return nil, err
}
src := internal.NewSource(archive, true, nil, -1)
src := internal.NewSource(archive, true, "[An external docker/tarfile caller]", nil, -1)
return &Source{internal: src}, nil
}