docker/tarfile/src.go
func NewSourceFromFile(path string) (*Source, error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, errors.Wrapf(err, "error opening file %q", path)
	}
	defer file.Close()

	// If the file is already not compressed we can just return the file itself
	// as a source. Otherwise we pass the stream to NewSourceFromStream.
	stream, isCompressed, err := compression.AutoDecompress(file)
	if err != nil {
		return nil, errors.Wrapf(err, "Error detecting compression for file %q", path)
	}
	defer stream.Close()
	if !isCompressed {
		return &Source{
			tarPath: path,
		}, nil
	}
	return NewSourceFromStream(stream)
}
func NewSourceFromFile(path string) (*Source, error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, errors.Wrapf(err, "error opening file %q", path)
	}
	defer file.Close()

	// If the file is already not compressed we can just return the file itself
	// as a source. Otherwise we pass the stream to NewSourceFromStream.
	stream, isCompressed, err := compression.AutoDecompress(file)
	if err != nil {
		return nil, errors.Wrapf(err, "Error detecting compression for file %q", path)
	}
	defer stream.Close()
	if !isCompressed {
		return &Source{
			tarPath: path,
		}, nil
	}
	return NewSourceFromStream(stream)
}
// TODO: We could add support for multiple images in a single archive, so
//       that people could use docker-archive:opensuse.tar:opensuse:leap as
//       the source of an image.
// 	To do for both the NewSourceFromFile and NewSourceFromStream functions
// NewSourceFromFile returns a tarfile.Source for the specified path.