tartest

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TarFromWriterTo

func TarFromWriterTo(wt WriterToTar) io.ReadCloser

TarFromWriterTo is used to create a tar stream from a tar record creator. This can be used to manufacture more specific tar records which allow testing specific tar cases which may be encountered by the untar process.

Types

type TarContext

type TarContext struct {
	UID int
	GID int

	// ModTime sets the modtimes for all files, if nil the current time
	// is used for each file when it was written
	ModTime *time.Time

	Xattrs map[string]string
}

TarContext is used to create tar records

func (TarContext) Dir

func (tc TarContext) Dir(name string, perm os.FileMode) WriterToTar

Dir returns a directory tar entry

func (TarContext) File

func (tc TarContext) File(name string, content []byte, perm os.FileMode) WriterToTar

File returns a regular file tar entry using the provided bytes

func (tc TarContext) Link(oldname, newname string) WriterToTar

Link returns a hard link tar entry

func (tc TarContext) Symlink(oldname, newname string) WriterToTar

Symlink returns a symlink tar entry

func (TarContext) WithModTime

func (tc TarContext) WithModTime(modtime time.Time) TarContext

WithModTime sets the ModTime for tar entries

func (TarContext) WithUIDGID

func (tc TarContext) WithUIDGID(uid, gid int) TarContext

WithUIDGID sets the UID and GID for tar entries

func (TarContext) WithXattrs

func (tc TarContext) WithXattrs(xattrs map[string]string) TarContext

WithXattrs adds these xattrs to all files, merges with any previously added xattrs

type WriterToTar

type WriterToTar interface {
	WriteTo(*tar.Writer) error
}

WriterToTar is an type which writes to a tar writer

func TarAll

func TarAll(wt ...WriterToTar) WriterToTar

TarAll creates a WriterToTar which calls all the provided writers in the order in which they are provided.

Jump to

Keyboard shortcuts

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