archive

package
v0.750.7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToIOReader

func ToIOReader(ar Archive) (io.Reader, error)

ToIOReader converts the files in an Archive to an io.Reader bytes buffer.

func ToRelocatedTarGz

func ToRelocatedTarGz(prefix string, ar Archive) ([]byte, error)

ToRelocatedTarGz converts the files in an Archive into a gzipped tarfile relocated with the specified path prefix.

func ToTarGz

func ToTarGz(ar Archive) ([]byte, error)

ToTarGz converts the files in an Archive into a gzipped tarfile.

func Write

func Write(dst string, a Archive, p func(level, log string) error) error

Write writes the given archive to the destination.

Types

type Archive

type Archive []Item

Archive contains an ordered list of Item objects, much like a tarball.

func FromTarGz

func FromTarGz(zippedTarfile []byte) (Archive, error)

FromTarGz converts a gzipped tarfile (in bytes) to an Archive.

func (Archive) ContainsFilePrefix

func (ar Archive) ContainsFilePrefix(prefix string) bool

ContainsFilePrefix returns true if any Item present in an Archive has the specified prefix (i.e. is under that directory).

func (Archive) ContainsPath

func (ar Archive) ContainsPath(path string) bool

ContainsPath returns if Item with the exact path given is present in an Archive.

type Item

type Item struct {
	// Path should include the filename.  For directories, it should not end in a '/'.
	Path string `json:"path"`
	// Type should match the tar.Header.Typeflag values.
	Type         byte        `json:"type"`
	Content      byteString  `json:"content"`
	FileMode     os.FileMode `json:"mode"`
	ModifiedTime UnixTime    `json:"mtime"`
	UserID       int         `json:"uid"`
	GroupID      int         `json:"gid"`
	IsRootItem   bool        `json:"isRootItem"`
}

Item is an in-memory representation of a file. It contains the content and additional metadata of a file.

func RootItem

func RootItem(path string, content []byte, mode int, fileType byte) Item

RootItem returns a new Item which will be owned by root when embedded in a container.

func UserItem

func UserItem(path string, content []byte, mode int, fileType byte, userID int, groupID int) Item

UserItem returns a new Item which will be owned by the user under which the container runs.

func (*Item) BaseName

func (i *Item) BaseName() string

BaseName returns the base name of the file.

func (*Item) DirName

func (i *Item) DirName() string

DirName returns the directory name of the file.

func (*Item) IsDir

func (i *Item) IsDir() bool

IsDir returns if the file is a directory.

func (i *Item) IsSymLink() bool

IsSymLink returns if the file is a soft link.

type UnixTime

type UnixTime struct {
	time.Time
}

UnixTime is a wrapper around time.Time that serializes to a Unix timestamp. This is a lossy conversion because time.Time also contains time zone and nanosecond information, so this type is only appropriate for dealing with legacy systems.

func (UnixTime) MarshalJSON

func (t UnixTime) MarshalJSON() ([]byte, error)

MarshalJSON marshals a UnixTime as seconds since the epoch.

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals seconds since the epoch into a UnixTime.

Jump to

Keyboard shortcuts

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