tar

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 490

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultExclusionPattern = regexp.MustCompile(`(^|/)\.git(/|$)`)

DefaultExclusionPattern is the pattern of files that will not be included in a tar file when creating one. By default it is any file inside a .git metadata directory

Functions

This section is empty.

Types

type ChmodAdapter added in v1.1.4

type ChmodAdapter struct {
	Writer
	NewFileMode     int64
	NewExecFileMode int64
	NewDirMode      int64
}

ChmodAdapter changes the mode of files and directories inline as a tarfile is being written

func (ChmodAdapter) WriteHeader added in v1.1.4

func (a ChmodAdapter) WriteHeader(hdr *tar.Header) error

WriteHeader changes the mode of files and directories inline as a tarfile is being written

type Reader added in v1.1.3

type Reader interface {
	io.Reader
	Next() (*tar.Header, error)
}

Reader is an interface which tar.Reader implements.

type RenameAdapter added in v1.1.4

type RenameAdapter struct {
	Writer
	Old string
	New string
}

RenameAdapter renames files and directories inline as a tarfile is being written

func (RenameAdapter) WriteHeader added in v1.1.4

func (a RenameAdapter) WriteHeader(hdr *tar.Header) error

WriteHeader renames files and directories inline as a tarfile is being written

type Tar

type Tar interface {
	// SetExclusionPattern sets the exclusion pattern for tar
	// creation
	SetExclusionPattern(*regexp.Regexp)

	// CreateTarFile creates a tar file in the base directory
	// using the contents of dir directory
	// The name of the new tar file is returned if successful
	CreateTarFile(base, dir string) (string, error)

	// CreateTarStreamToTarWriter creates a tar from the given directory
	// and streams it to the given writer.
	// An error is returned if an error occurs during streaming.
	// Archived file names are written to the logger if provided
	CreateTarStreamToTarWriter(dir string, includeDirInPath bool, writer Writer, logger io.Writer) error

	// CreateTarStream creates a tar from the given directory
	// and streams it to the given writer.
	// An error is returned if an error occurs during streaming.
	CreateTarStream(dir string, includeDirInPath bool, writer io.Writer) error

	// CreateTarStreamReader returns an io.ReadCloser from which a tar stream can be
	// read.  The tar stream is created using CreateTarStream.
	CreateTarStreamReader(dir string, includeDirInPath bool) io.ReadCloser

	// ExtractTarStream extracts files from a given tar stream.
	// Times out if reading from the stream for any given file
	// exceeds the value of timeout.
	ExtractTarStream(dir string, reader io.Reader) error

	// ExtractTarStreamWithLogging extracts files from a given tar stream.
	// Times out if reading from the stream for any given file
	// exceeds the value of timeout.
	// Extracted file names are written to the logger if provided.
	ExtractTarStreamWithLogging(dir string, reader io.Reader, logger io.Writer) error

	// ExtractTarStreamFromTarReader extracts files from a given tar stream.
	// Times out if reading from the stream for any given file
	// exceeds the value of timeout.
	// Extracted file names are written to the logger if provided.
	ExtractTarStreamFromTarReader(dir string, tarReader Reader, logger io.Writer) error
}

Tar can create and extract tar files used in an STI build

func New

func New(fs fs.FileSystem) Tar

New creates a new Tar

func NewParanoid added in v1.1.10

func NewParanoid(fs fs.FileSystem) Tar

NewParanoid creates a new Tar that has restrictions on what it can do while extracting files.

func NewParanoidWithTimeout added in v1.1.14

func NewParanoidWithTimeout(fs fs.FileSystem, timeout time.Duration) Tar

NewParanoidWithTimeout creates a new Tar with the provided timeout extracting files. It has restrictions on what it can do while extracting files.

func NewWithTimeout added in v1.1.14

func NewWithTimeout(fs fs.FileSystem, timeout time.Duration) Tar

NewWithTimeout creates a new Tar with the provided timeout extracting files.

type Writer added in v1.1.4

type Writer interface {
	io.WriteCloser
	Flush() error
	WriteHeader(hdr *tar.Header) error
}

Writer is an interface which tar.Writer implements.

Jump to

Keyboard shortcuts

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