extract

package
v1.23.1-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(origReader io.Reader, destFolder string, options ...Option) error

func UnzipFolder

func UnzipFolder(source, destination string) error

func WriteTar

func WriteTar(writer io.Writer, localPath string, compress bool) error

func WriteTarExclude

func WriteTarExclude(
	writer io.Writer,
	localPath string,
	compress bool,
	excludedPaths []string,
) error

func WriteTarWithOptions added in v1.23.1

func WriteTarWithOptions(writer io.Writer, localPath string, opts TarOptions) error

WriteTarWithOptions archives a file or a directory's contents.

Types

type Archiver

type Archiver struct {
	// contains filtered or unexported fields
}

func NewArchiver

func NewArchiver(basePath string, writer *tar.Writer, excludedPaths []string) (*Archiver, error)

func (*Archiver) AddToArchive

func (a *Archiver) AddToArchive(relativePath string) error

type Option

type Option func(o *Options)

func PreserveHeaderOwnership added in v1.17.0

func PreserveHeaderOwnership() Option

PreserveHeaderOwnership makes Extract apply each entry's tar-header uid/gid.

func StripLevels

func StripLevels(levels int) Option

type Options

type Options struct {
	StripLevels       int
	Perm              *os.FileMode
	UID               *int
	GID               *int
	PreserveOwnership bool
}

type ProtectedFile added in v1.23.1

type ProtectedFile struct {
	Reader io.Reader
	Size   int64
}

type TarOptions added in v1.23.1

type TarOptions struct {
	Compress bool
	// Docker ignore patterns relative to the archive root.
	Excludes []string
	// Overrides Excludes; lazy compilation prevents sharing across transfers.
	Matcher *patternmatcher.PatternMatcher
	// Exact root-relative paths that bypass exclusions; symlink components are rejected.
	ProtectedPaths []string
	// Immutable bodies for exact paths; the caller owns and closes their readers.
	ProtectedFiles map[string]ProtectedFile
	// ProtectedSymlinks archives approved link targets without dereferencing them.
	ProtectedSymlinks map[string]string
	// Exact directory headers bypass exclusions; their children retain normal filtering.
	ProtectedDirectories []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL