copier

package
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 20 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(root string, directory string, options GetOptions, globs []string, bulkWriter io.Writer) error

Get produces an archive containing items that match the specified glob patterns and writes it to bulkWriter. If root and directory are both not specified, the current root directory is used, and relative names in the globs list are treated as being relative to the current working directory. If root is specified and the current OS supports it, the contents are read in a chrooted context. If the directory is specified as an absolute path, it should either be the root directory or a subdirectory of the root directory. Otherwise, the directory is treated as a path relative to the root directory. Relative names in the glob list are treated as being relative to the directory.

func Lgetxattrs

func Lgetxattrs(path string) (map[string]string, error)

Lgetxattrs returns a map of the relevant extended attributes set on the given file.

func Lsetxattrs

func Lsetxattrs(path string, xattrs map[string]string) error

Lsetxattrs sets the relevant members of the specified extended attributes on the given file.

func Mkdir

func Mkdir(root string, directory string, options MkdirOptions) error

Mkdir ensures that the specified directory exists. Any directories which need to be created will be given the specified ownership and permissions. If root and directory are both not specified, the current root directory is used. If root is specified and the current OS supports it, the directory is created in a chrooted context. If the directory is specified as an absolute path, it should either be the root directory or a subdirectory of the root directory. Otherwise, the directory is treated as a path relative to the root directory.

func Put

func Put(root string, directory string, options PutOptions, bulkReader io.Reader) error

Put extracts an archive from the bulkReader at the specified directory. If root and directory are both not specified, the current root directory is used. If root is specified and the current OS supports it, the contents are written in a chrooted context. If the directory is specified as an absolute path, it should either be the root directory or a subdirectory of the root directory. Otherwise, the directory is treated as a path relative to the root directory.

Types

type GetOptions

type GetOptions struct {
	UIDMap, GIDMap     []idtools.IDMap // map from hostIDs to containerIDs in the output archive
	Excludes           []string        // contents to pretend don't exist, using the OS-specific path separator
	ExpandArchives     bool            // extract the contents of named items that are archives
	ChownDirs          *idtools.IDPair // set ownership on directories. no effect on archives being extracted
	ChmodDirs          *os.FileMode    // set permissions on directories. no effect on archives being extracted
	ChownFiles         *idtools.IDPair // set ownership of files. no effect on archives being extracted
	ChmodFiles         *os.FileMode    // set permissions on files. no effect on archives being extracted
	StripSetuidBit     bool            // strip the setuid bit off of items being copied. no effect on archives being extracted
	StripSetgidBit     bool            // strip the setgid bit off of items being copied. no effect on archives being extracted
	StripStickyBit     bool            // strip the sticky bit off of items being copied. no effect on archives being extracted
	StripXattrs        bool            // don't record extended attributes of items being copied. no effect on archives being extracted
	KeepDirectoryNames bool            // don't strip the top directory's basename from the paths of items in subdirectories
}

GetOptions controls parts of Get()'s behavior.

type MkdirOptions

type MkdirOptions struct {
	UIDMap, GIDMap []idtools.IDMap // map from containerIDs to hostIDs when creating directories
	ChownNew       *idtools.IDPair // set ownership of newly-created directories
	ChmodNew       *os.FileMode    // set permissions on newly-created directories
}

MkdirOptions controls parts of Mkdir()'s behavior.

type PutOptions

type PutOptions struct {
	UIDMap, GIDMap    []idtools.IDMap // map from containerIDs to hostIDs when writing contents to disk
	DefaultDirOwner   *idtools.IDPair // set ownership of implicitly-created directories, default is ChownDirs, or 0:0 if ChownDirs not set
	DefaultDirMode    *os.FileMode    // set permissions on implicitly-created directories, default is ChmodDirs, or 0755 if ChmodDirs not set
	ChownDirs         *idtools.IDPair // set ownership of newly-created directories
	ChmodDirs         *os.FileMode    // set permissions on newly-created directories
	ChownFiles        *idtools.IDPair // set ownership of newly-created files
	ChmodFiles        *os.FileMode    // set permissions on newly-created files
	StripXattrs       bool            // don't bother trying to set extended attributes of items being copied
	IgnoreXattrErrors bool            // ignore any errors encountered when attempting to set extended attributes
}

PutOptions controls parts of Put()'s behavior.

type StatForItem

type StatForItem struct {
	Error           string `json:",omitempty"`
	Name            string
	Size            int64       // dereferenced value for symlinks
	Mode            os.FileMode // dereferenced value for symlinks
	ModTime         time.Time   // dereferenced value for symlinks
	IsSymlink       bool
	IsDir           bool   // dereferenced value for symlinks
	IsRegular       bool   // dereferenced value for symlinks
	IsArchive       bool   // dereferenced value for symlinks
	ImmediateTarget string `json:",omitempty"` // raw link content
}

StatForItem encode results for a single filesystem item, as returned by Stat().

type StatOptions

type StatOptions struct {
	CheckForArchives bool     // check for and populate the IsArchive bit in returned values
	Excludes         []string // contents to pretend don't exist, using the OS-specific path separator
}

StatOptions controls parts of Stat()'s behavior.

type StatsForGlob

type StatsForGlob struct {
	Error   string                  `json:",omitempty"` // error if the Glob pattern was malformed
	Glob    string                  // input pattern to which this result corresponds
	Globbed []string                // a slice of zero or more names that match the glob
	Results map[string]*StatForItem // one for each Globbed value if there are any, or for Glob
}

StatsForGlob encode results for a single glob pattern passed to Stat().

func Stat

func Stat(root string, directory string, options StatOptions, globs []string) ([]*StatsForGlob, error)

Stat globs the specified pattern in the specified directory and returns its results. If root and directory are both not specified, the current root directory is used, and relative names in the globs list are treated as being relative to the current working directory. If root is specified and the current OS supports it, the stat() is performed in a chrooted context. If the directory is specified as an absolute path, it should either be the root directory or a subdirectory of the root directory. Otherwise, the directory is treated as a path relative to the root directory. Relative names in the glob list are treated as being relative to the directory.

Jump to

Keyboard shortcuts

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