Documentation ¶
Index ¶
- Variables
- func AssertArchiveHasFiles(c *C, r io.ReadCloser, excludePatterns []string, filenames ...string)
- func AssertArchiveHasItems(c *C, r io.ReadCloser, excludePatterns []string, items ...TestItem)
- func AssertDirHasFiles(c *C, dir string, files ...TestFile)
- func CompressDirectory(dir string, writer io.Writer, items ...*Item) error
- func CreateMemArchive(items []*Item) (*bytes.Buffer, error)
- func DefaultOptions() *dockerarchive.TarOptions
- func Extract(r io.Reader, dir string) error
- func ExtractWithPrefix(r io.Reader, dir, tarDirPrefix string) error
- func FetchFiles(r io.ReadCloser, excludePatterns []string) (map[string]string, error)
- func GetChownOptionsForDir(dir string) (*idtools.Identity, error)
- func HasFile(tarballPath, filename string) error
- func MustCreateMemArchive(items []*Item) *bytes.Buffer
- func PathMatch(pattern PathPattern, path string) (bool, error)
- func SanitizeTarPath(header *tar.Header, dir string) error
- func TarGlob(source *tar.Reader, dir string, patterns []string, ...) (err error)
- func TarGlobWithPrefix(source *tar.Reader, prefix string, handler TarGlobHandler) (err error)
- func Unpack(path string) (unpackedDir string, err error)
- type Filename
- type Item
- type NameMatcher
- type PathPattern
- type TarAppender
- type TarGlobHandler
- type TestFile
- type TestItem
Constants ¶
This section is empty.
Variables ¶
var ErrAbort = errors.New("abort iteration")
ErrAbort is a special error value used to abort an iteration
Functions ¶
func AssertArchiveHasFiles ¶
func AssertArchiveHasFiles(c *C, r io.ReadCloser, excludePatterns []string, filenames ...string)
AssertArchiveHasFiles validates that filenames are in the archive r.
func AssertArchiveHasItems ¶
func AssertArchiveHasItems(c *C, r io.ReadCloser, excludePatterns []string, items ...TestItem)
AssertArchiveHasItems validates that items are in the archive r.
func AssertDirHasFiles ¶
AssertDirHasFiles validates that directory dir has files.
func CompressDirectory ¶
CompressDirectory compresses the directory given with dir, using writer as a sink for the archive
func CreateMemArchive ¶
CreateMemArchive creates in-memory archive from archive items
func DefaultOptions ¶
func DefaultOptions() *dockerarchive.TarOptions
DefaultOptions returns an options object with sensible defaults
func Extract ¶
Extract extracts the contents of the specified tarball under dir. The resulting files and directories are created using the current user context.
func ExtractWithPrefix ¶
ExtractWithPrefix extracts the contents of the specified tarball under directory dir. Only the files/directories found in tarDirPrefix in the tarball matching patterns are extracted. Note, files from tarDir are written directly to dir omitting tarDir. The resulting files and directories are created using the current user context.
func FetchFiles ¶
FetchFiles fetches archive files as map
func GetChownOptionsForDir ¶
GetChownOptionsForDir returns the ownership options for the specified directory dir. It will use the same options if directory already exists, and will fall back to current user otherwise
func MustCreateMemArchive ¶
MustCreateMemArchive creates in-memory archive from archive items
func PathMatch ¶
func PathMatch(pattern PathPattern, path string) (bool, error)
PathMatch matches path against the specified path pattern. The pattern can use double-asterisks (`**`) to denote arbitrary intermediate directories in the path. Returns True upon a successful match and error if the pattern is invalid. Based on docker/docker/pkg/fileutils/fileutils#regexpMatch
func SanitizeTarPath ¶
SanitizeTarPath checks that the tar header paths resolve to a subdirectory path, and don't contain file paths or links that could escape the tar file (e.g. ../../etc/passwrd)
func TarGlob ¶
func TarGlob(source *tar.Reader, dir string, patterns []string, handler func(match string, file io.Reader) error) (err error)
TarGlob iterates the contents of the specified tarball and invokes handler for each file matching the list of specified patterns. If the handler returns a special Abort error, iteration will be aborted without errors.
func TarGlobWithPrefix ¶
func TarGlobWithPrefix(source *tar.Reader, prefix string, handler TarGlobHandler) (err error)
TarGlobWithPrefix iterates the contents of the specified tarball and invokes handler for each file in the directory with the specified prefix (and all its sub-directories). If the handler returns a special Abort error, iteration will be aborted without errors.
Types ¶
type Item ¶
type Item struct { tar.Header // Data is the data payload Data io.ReadCloser }
Item defines a unit of compression
func ItemFromFile ¶
ItemFromFile creates an Item from the specified file
func ItemFromStream ¶
func ItemFromStream(path string, rc io.ReadCloser, size, mode int64) *Item
ItemFromStream creates an Item from given io.ReadCloser
func ItemFromString ¶
ItemFromString creates an Item from given string
func ItemFromStringMode ¶
ItemFromStringMode creates a new Item from a given string with the provided permissions
type NameMatcher ¶
type TarAppender ¶
type TarAppender struct {
// contains filtered or unexported fields
}
TarAppender wraps a tar writer and can append items to it
func NewTarAppender ¶
func NewTarAppender(w io.Writer) *TarAppender
NewTarAppender creates a new tar appender writing to w
func (*TarAppender) Add ¶
func (r *TarAppender) Add(items ...*Item) (err error)
Add adds the specified items to the underlined archive
type TarGlobHandler ¶
TarGlobHandler defines a handler for the match when iterating files in the tarball r.