Documentation
¶
Overview ¶
Package archive provides helper functions for dealing with archive files.
Index ¶
- Constants
- Variables
- func ApplyLayer(dest string, layer io.Reader) (int64, error)deprecated
- func ApplyUncompressedLayer(dest string, layer io.Reader, options *TarOptions) (int64, error)deprecated
- func Changes(layers []string, rw string) ([]archive.Change, error)deprecated
- func ChangesDirs(newDir, oldDir string) ([]archive.Change, error)deprecated
- func ChangesSize(newDir string, changes []archive.Change) int64deprecated
- func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error)deprecated
- func CompressStream(dest io.Writer, comp compression.Compression) (io.WriteCloser, error)deprecated
- func CopyInfoDestinationPath(path string) (info archive.CopyInfo, err error)deprecated
- func CopyInfoSourcePath(path string, followLink bool) (archive.CopyInfo, error)deprecated
- func CopyResource(srcPath, dstPath string, followLink bool) errordeprecated
- func CopyTo(content io.Reader, srcInfo archive.CopyInfo, dstPath string) errordeprecated
- func DecompressStream(arch io.Reader) (io.ReadCloser, error)deprecated
- func DetectCompression(source []byte) archive.Compressiondeprecated
- func ExportChanges(dir string, changes []archive.Change, idMap idtools.IdentityMapping) (io.ReadCloser, error)
- func FileInfoHeader(name string, fi os.FileInfo, link string) (*tar.Header, error)deprecated
- func FileInfoHeaderNoLookups(fi os.FileInfo, link string) (*tar.Header, error)deprecated
- func Generate(input ...string) (io.Reader, error)deprecated
- func GetRebaseName(path, resolvedPath string) (string, string)deprecated
- func IsArchivePath(path string) booldeprecated
- func IsEmpty(rd io.Reader) (bool, error)deprecated
- func NewTarballer(srcPath string, options *TarOptions) (*archive.Tarballer, error)deprecated
- func PrepareArchiveCopy(srcContent io.Reader, srcInfo, dstInfo archive.CopyInfo) (dstDir string, content io.ReadCloser, err error)deprecated
- func PreserveTrailingDotOrSeparator(cleanedPath string, originalPath string) stringdeprecated
- func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) errordeprecated
- func RebaseArchiveEntries(srcContent io.Reader, oldBase, newBase string) io.ReadCloserdeprecated
- func ReplaceFileTarWrapper(inputTarStream io.ReadCloser, mods map[string]archive.TarModifierFunc) io.ReadCloserdeprecated
- func ResolveHostSourcePath(path string, followLink bool) (resolvedPath, rebaseName string, _ error)deprecated
- func SplitPathDirEntry(path string) (dir, base string)deprecated
- func Tar(path string, compression archive.Compression) (io.ReadCloser, error)deprecated
- func TarResource(sourceInfo archive.CopyInfo) (content io.ReadCloser, err error)deprecated
- func TarResourceRebase(sourcePath, rebaseName string) (content io.ReadCloser, _ error)deprecated
- func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)deprecated
- func ToArchiveOpt(options *TarOptions) *archive.TarOptionsdeprecated
- func Unpack(decompressedArchive io.Reader, dest string, options *TarOptions) errordeprecated
- func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, err error)deprecated
- func Untar(tarArchive io.Reader, dest string, options *TarOptions) errordeprecated
- func UntarUncompressed(tarArchive io.Reader, dest string, options *TarOptions) errordeprecated
- type Archiverdeprecated
- func NewDefaultArchiver() *Archiverdeprecated
- func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error)
- func (archiver *Archiver) CopyWithTar(src, dst string) error
- func (archiver *Archiver) IdentityMapping() idtools.IdentityMapping
- func (archiver *Archiver) TarUntar(src, dst string) error
- func (archiver *Archiver) UntarPath(src, dst string) error
- type Changedeprecated
- type ChangeTypedeprecated
- type Compressiondeprecated
- type CopyInfodeprecated
- type FileInfodeprecated
- type TarModifierFuncdeprecated
- type TarOptionsdeprecated
- type Tarballerdeprecated
- type WhiteoutFormatdeprecated
Constants ¶
const ( Uncompressed = compression.None // Deprecated: use [compression.None] instead. Bzip2 = compression.Bzip2 // Deprecated: use [compression.Bzip2] instead. Gzip = compression.Gzip // Deprecated: use [compression.Gzip] instead. Xz = compression.Xz // Deprecated: use [compression.Xz] instead. Zstd = compression.Zstd // Deprecated: use [compression.Zstd] instead. )
const ( AUFSWhiteoutFormat = archive.AUFSWhiteoutFormat // Deprecated: use [archive.AUFSWhiteoutFormat] instead. OverlayWhiteoutFormat = archive.OverlayWhiteoutFormat // Deprecated: use [archive.OverlayWhiteoutFormat] instead. )
const ( ChangeModify = archive.ChangeModify // Deprecated: use [archive.ChangeModify] instead. ChangeAdd = archive.ChangeAdd // Deprecated: use [archive.ChangeAdd] instead. ChangeDelete = archive.ChangeDelete // Deprecated: use [archive.ChangeDelete] instead. )
const ( WhiteoutPrefix = archive.WhiteoutPrefix // Deprecated: use [archive.WhiteoutPrefix] instead. WhiteoutMetaPrefix = archive.WhiteoutMetaPrefix // Deprecated: use [archive.WhiteoutMetaPrefix] instead. WhiteoutLinkDir = archive.WhiteoutLinkDir // Deprecated: use [archive.WhiteoutLinkDir] instead. WhiteoutOpaqueDir = archive.WhiteoutOpaqueDir // Deprecated: use [archive.WhiteoutOpaqueDir] instead. )
const ImpliedDirectoryMode = archive.ImpliedDirectoryMode
ImpliedDirectoryMode represents the mode (Unix permissions) applied to directories that are implied by files in a tar, but that do not have their own header entry.
Deprecated: use archive.ImpliedDirectoryMode instead.
Variables ¶
var ( ErrNotDirectory = archive.ErrNotDirectory // Deprecated: use [archive.ErrNotDirectory] instead. ErrDirNotExists = archive.ErrDirNotExists // Deprecated: use [archive.ErrDirNotExists] instead. ErrCannotCopyDir = archive.ErrCannotCopyDir // Deprecated: use [archive.ErrCannotCopyDir] instead. ErrInvalidCopySource = archive.ErrInvalidCopySource // Deprecated: use [archive.ErrInvalidCopySource] instead. )
Functions ¶
func ApplyLayer
deprecated
func ApplyUncompressedLayer
deprecated
added in
v1.8.0
ApplyUncompressedLayer parses a diff in the standard layer format from `layer`, and applies it to the directory `dest`.
Deprecated: use archive.ApplyUncompressedLayer instead.
func Changes
deprecated
Changes walks the path rw and determines changes for the files in the path, with respect to the parent layers
Deprecated: use archive.Changes instead.
func ChangesDirs
deprecated
ChangesDirs compares two directories and generates an array of Change objects describing the changes.
Deprecated: use archive.ChangesDirs instead.
func ChangesSize
deprecated
ChangesSize calculates the size in bytes of the provided changes, based on newDir.
Deprecated: use archive.ChangesSize instead.
func CheckSystemDriveAndRemoveDriveLetter
deprecated
CheckSystemDriveAndRemoveDriveLetter verifies that a path is the system drive.
Deprecated: use archive.CheckSystemDriveAndRemoveDriveLetter instead.
func CompressStream
deprecated
func CompressStream(dest io.Writer, comp compression.Compression) (io.WriteCloser, error)
CompressStream compresses the dest with specified compression algorithm.
Deprecated: use compression.CompressStream instead.
func CopyInfoDestinationPath
deprecated
added in
v1.8.0
CopyInfoDestinationPath stats the given path to create a CopyInfo struct representing that resource for the destination of an archive copy operation.
Deprecated: use archive.CopyInfoDestinationPath instead.
func CopyInfoSourcePath
deprecated
added in
v1.8.0
CopyInfoSourcePath stats the given path to create a CopyInfo struct. struct representing that resource for the source of an archive copy operation.
Deprecated: use archive.CopyInfoSourcePath instead.
func CopyResource
deprecated
added in
v1.8.0
CopyResource performs an archive copy from the given source path to the given destination path.
Deprecated: use archive.CopyResource instead.
func DecompressStream
deprecated
func DecompressStream(arch io.Reader) (io.ReadCloser, error)
DecompressStream decompresses the archive and returns a ReaderCloser with the decompressed archive.
Deprecated: use compression.DecompressStream instead.
func DetectCompression
deprecated
func DetectCompression(source []byte) archive.Compression
DetectCompression detects the compression algorithm of the source.
Deprecated: use compression.Detect instead.
func ExportChanges ¶
func ExportChanges(dir string, changes []archive.Change, idMap idtools.IdentityMapping) (io.ReadCloser, error)
ExportChanges produces an Archive from the provided changes, relative to dir.
func FileInfoHeader
deprecated
func FileInfoHeaderNoLookups
deprecated
func GetRebaseName
deprecated
added in
v1.10.0
GetRebaseName normalizes and compares path and resolvedPath.
Deprecated: use archive.GetRebaseName instead.
func IsArchivePath
deprecated
added in
v1.10.0
IsArchivePath checks if the (possibly compressed) file at the given path starts with a tar file header.
Deprecated: use archive.IsArchivePath instead.
func NewTarballer
deprecated
func NewTarballer(srcPath string, options *TarOptions) (*archive.Tarballer, error)
NewTarballer constructs a new tarballer using TarWithOptions.
Deprecated: use archive.Tarballer instead.
func PrepareArchiveCopy
deprecated
added in
v1.8.0
func PrepareArchiveCopy(srcContent io.Reader, srcInfo, dstInfo archive.CopyInfo) (dstDir string, content io.ReadCloser, err error)
PrepareArchiveCopy prepares the given srcContent archive.
Deprecated: use archive.PrepareArchiveCopy instead.
func PreserveTrailingDotOrSeparator
deprecated
added in
v1.8.0
PreserveTrailingDotOrSeparator returns the given cleaned path.
Deprecated: use archive.PreserveTrailingDotOrSeparator instead.
func ReadSecurityXattrToTarHeader
deprecated
ReadSecurityXattrToTarHeader reads security.capability xattr from filesystem to a tar header
Deprecated: use archive.ReadSecurityXattrToTarHeader instead.
func RebaseArchiveEntries
deprecated
added in
v1.10.0
func RebaseArchiveEntries(srcContent io.Reader, oldBase, newBase string) io.ReadCloser
RebaseArchiveEntries rewrites the given srcContent archive replacing an occurrence of oldBase with newBase at the beginning of entry names.
Deprecated: use archive.RebaseArchiveEntries instead.
func ReplaceFileTarWrapper
deprecated
func ReplaceFileTarWrapper(inputTarStream io.ReadCloser, mods map[string]archive.TarModifierFunc) io.ReadCloser
ReplaceFileTarWrapper converts inputTarStream to a new tar stream.
Deprecated: use archive.ReplaceFileTarWrapper instead.
func ResolveHostSourcePath
deprecated
added in
v1.10.0
ResolveHostSourcePath decides real path need to be copied.
Deprecated: use archive.ResolveHostSourcePath instead.
func SplitPathDirEntry
deprecated
added in
v1.8.0
SplitPathDirEntry splits the given path between its directory name and its basename.
Deprecated: use archive.SplitPathDirEntry instead.
func Tar
deprecated
func Tar(path string, compression archive.Compression) (io.ReadCloser, error)
Tar creates an archive from the directory at `path`, and returns it as a stream of bytes.
Deprecated: use archive.Tar instead.
func TarResource
deprecated
added in
v1.8.0
func TarResource(sourceInfo archive.CopyInfo) (content io.ReadCloser, err error)
TarResource archives the resource described by the given CopyInfo to a Tar archive.
Deprecated: use archive.TarResource instead.
func TarResourceRebase
deprecated
added in
v1.8.0
func TarResourceRebase(sourcePath, rebaseName string) (content io.ReadCloser, _ error)
TarResourceRebase is like TarResource but renames the first path element of items in the resulting tar archive to match the given rebaseName if not "".
Deprecated: use archive.TarResourceRebase instead.
func TarWithOptions
deprecated
func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
TarWithOptions creates an archive with the given options.
Deprecated: use archive.TarWithOptions instead.
func ToArchiveOpt
deprecated
func ToArchiveOpt(options *TarOptions) *archive.TarOptions
ToArchiveOpt converts an TarOptions to a archive.TarOptions.
Deprecated: use archive.TarOptions instead, this utility is for internal use to transition to the github.com/moby/go-archive module.
func Unpack
deprecated
added in
v1.3.3
func Unpack(decompressedArchive io.Reader, dest string, options *TarOptions) error
Unpack unpacks the decompressedArchive to dest with options.
Deprecated: use archive.Unpack instead.
func UnpackLayer
deprecated
added in
v1.3.3
UnpackLayer unpack `layer` to a `dest`.
Deprecated: use archive.UnpackLayer instead.
func Untar
deprecated
func Untar(tarArchive io.Reader, dest string, options *TarOptions) error
Untar reads a stream of bytes from `archive`, parses it as a tar archive, and unpacks it into the directory at `dest`.
Deprecated: use archive.Untar instead.
func UntarUncompressed
deprecated
added in
v1.8.0
func UntarUncompressed(tarArchive io.Reader, dest string, options *TarOptions) error
UntarUncompressed reads a stream of bytes from `tarArchive`, parses it as a tar archive, and unpacks it into the directory at `dest`. The archive must be an uncompressed stream.
Deprecated: use archive.UntarUncompressed instead.
Types ¶
type Archiver
deprecated
added in
v1.3.2
type Archiver struct { Untar func(io.Reader, string, *TarOptions) error IDMapping idtools.IdentityMapping }
Archiver implements the Archiver interface and allows the reuse of most utility functions of this package with a pluggable Untar function. Also, to facilitate the passing of specific id mappings for untar, an Archiver can be created with maps which will then be passed to Untar operations.
Deprecated: use archive.Archiver instead.
func NewDefaultArchiver
deprecated
func NewDefaultArchiver() *Archiver
NewDefaultArchiver returns a new Archiver without any IdentityMapping
Deprecated: use archive.NewDefaultArchiver instead.
func (*Archiver) CopyFileWithTar ¶ added in v1.3.2
CopyFileWithTar emulates the behavior of the 'cp' command-line for a single file. It copies a regular file from path `src` to path `dst`, and preserves all its metadata.
func (*Archiver) CopyWithTar ¶ added in v1.3.2
CopyWithTar creates a tar archive of filesystem path `src`, and unpacks it at filesystem path `dst`. The archive is streamed directly with fixed buffering and no intermediary disk IO.
func (*Archiver) IdentityMapping ¶
func (archiver *Archiver) IdentityMapping() idtools.IdentityMapping
IdentityMapping returns the IdentityMapping of the archiver.
type Change
deprecated
type ChangeType
deprecated
type ChangeType = archive.ChangeType
ChangeType represents the change
Deprecated: use archive.ChangeType instead.
type Compression
deprecated
type Compression = compression.Compression
Compression is the state represents if compressed or not.
Deprecated: use compression.Compression instead.
type CopyInfo
deprecated
added in
v1.8.0
type CopyInfo = archive.CopyInfo
CopyInfo holds basic info about the source or destination path of a copy operation.
Deprecated: use archive.CopyInfo instead.
type FileInfo
deprecated
type FileInfo = archive.FileInfo
FileInfo describes the information of a file.
Deprecated: use archive.FileInfo instead.
type TarModifierFunc
deprecated
type TarModifierFunc = archive.TarModifierFunc
TarModifierFunc is a function that can be passed to ReplaceFileTarWrapper.
Deprecated: use archive.TarModifierFunc instead.
type TarOptions
deprecated
type TarOptions struct { IncludeFiles []string ExcludePatterns []string Compression compression.Compression NoLchown bool IDMap idtools.IdentityMapping ChownOpts *idtools.Identity IncludeSourceDir bool // WhiteoutFormat is the expected on disk format for whiteout files. // This format will be converted to the standard format on pack // and from the standard format on unpack. WhiteoutFormat archive.WhiteoutFormat // When unpacking, specifies whether overwriting a directory with a // non-directory is allowed and vice versa. NoOverwriteDirNonDir bool // For each include when creating an archive, the included name will be // replaced with the matching name from this map. RebaseNames map[string]string InUserNS bool // Allow unpacking to succeed in spite of failures to set extended // attributes on the unpacked files due to the destination filesystem // not supporting them or a lack of permissions. Extended attributes // were probably in the archive for a reason, so set this option at // your own peril. BestEffortXattrs bool }
TarOptions wraps the tar options.
Deprecated: use archive.TarOptions instead.
func TarResourceRebaseOpts
deprecated
func TarResourceRebaseOpts(sourceBase string, rebaseName string) *TarOptions
TarResourceRebaseOpts does not preform the Tar, but instead just creates the rebase parameters to be sent to TarWithOptions.
Deprecated: use archive.TarResourceRebaseOpts instead.
type Tarballer
deprecated
type Tarballer = archive.Tarballer
Tarballer is a lower-level interface to TarWithOptions.
Deprecated: use archive.Tarballer instead.
type WhiteoutFormat
deprecated
added in
v1.12.0
type WhiteoutFormat = archive.WhiteoutFormat
WhiteoutFormat is the format of whiteouts unpacked
Deprecated: use archive.WhiteoutFormat instead.