tar

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: Apache-2.0 Imports: 13 Imported by: 15

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

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

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

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

Reader is an interface which tar.Reader implements.

type RenameAdapter

type RenameAdapter struct {
	Writer
	Old string
	New string
}

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

func (RenameAdapter) WriteHeader

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

func NewParanoid(fs fs.FileSystem) Tar

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

type Writer

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