layercopy

package
v1.0.0-beta.27 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveSelectionPath

func ResolveSelectionPath(entries SelectionSource, name string) (string, error)

ResolveSelectionPath expands a path through the same confined entry source and symlink budget used by CopySelection. Missing mountpoint parents can be supplied as synthetic directories by the source.

func ResolveWildcards

func ResolveWildcards(root, src string, followLinks bool) ([]string, error)

Types

type Copier

type Copier struct {
	// contains filtered or unexported fields
}

func NewCopier

func NewCopier(dest Mount) (*Copier, error)

func (*Copier) Close

func (c *Copier) Close() error

func (*Copier) Copy

func (c *Copier) Copy(ctx context.Context, src Mount, srcPath, destPath string, opts CopyOptions) error

func (*Copier) CopyFile

func (c *Copier) CopyFile(ctx context.Context, src Mount, srcPath, destPath string, opts CopyOptions) error

func (*Copier) CopyFileFromLayer

func (c *Copier) CopyFileFromLayer(ctx context.Context, layer, srcPath, destPath string, opts CopyOptions) (bool, error)

CopyFileFromLayer copies srcPath as CopyFile does, read from layer, the directory of a snapshot's topmost layer, with no mount of the snapshot. It takes only a non-empty regular file reached through real directories in that layer, which is the file the snapshot shows whatever the layers below hold. An empty one may be an overlay whiteout, which a regular file can be. For anything else it reports false, and the caller uses CopyFile: the path isn't in the layer, or is a whiteout or symlink there, or a component of it is, or the layer or file has gone. Only a file that goes from under the copy can have changed the destination by then, by replacing what destPath held; before that, nothing has.

func (*Copier) CopySelection

func (c *Copier) CopySelection(ctx context.Context, root, name string, options ...SelectionOptions) error

CopySelection copies a directory to the destination root. It repairs links that would break when the parent is removed, and preserves other links, including links that already have no target. The source is a mounted view or a logical mount table; filters and raw overlay layers are not accepted.

func (c *Copier) ForgetSourceLinks()

ForgetSourceLinks makes later copies independent of earlier ones, as with a new Copier for the same destination: a source file copied before is linked or copied from its source again, not linked to its earlier destination, which a later copy may have replaced. Usage accounting is kept.

func (*Copier) MaterializeDestDir

func (c *Copier) MaterializeDestDir(ctx context.Context, destPath string) (string, error)

func (*Copier) Mkdir

func (c *Copier) Mkdir(ctx context.Context, destPath string, opts CopyOptions) error

func (*Copier) Usage

func (c *Copier) Usage() (snapshots.Usage, error)

type CopyOptions

type CopyOptions struct {
	Filter            Filter
	Chown             *Ownership
	Mode              *os.FileMode
	XAttrErrorHandler XAttrErrorHandler
	DisableXAttrs     bool
	CopyDirContents   bool
	ReplaceExisting   bool
	DestPathHintIsDir bool

	// DisableHardlinks disables all hardlink creation, including hardlink
	// preservation between entries created by this copy.
	DisableHardlinks bool

	// DisableSourceHardlinks disables hardlinking from source paths into the
	// destination while still preserving hardlinks within this copy.
	DisableSourceHardlinks bool
}

type Filter

type Filter struct {
	Only      map[string]struct{}
	Include   []string
	Exclude   []string
	Gitignore bool
}

type Mount

type Mount struct {
	Root  string
	Mount *mount.Mount
}

type Ownership

type Ownership struct {
	UID int
	GID int
}

type PathTree

type PathTree struct {
	// contains filtered or unexported fields
}

PathTree is a directory tree known only from its paths, such as a Git tree whose files aren't on disk. It answers what a copy of the tree would select without reading any file.

func NewPathTree

func NewPathTree(files []string) *PathTree

NewPathTree builds a tree from the slash-separated paths of everything in it that isn't a directory. Their parents are its directories.

func (*PathTree) FileCount

func (t *PathTree) FileCount(rel string) int

FileCount returns how many files are below the directory rel, at any depth.

func (*PathTree) IsDir

func (t *PathTree) IsDir(rel string) bool

IsDir reports whether rel, a slash-separated path from the tree's root, is one of its directories.

func (*PathTree) SelectedFiles

func (t *PathTree) SelectedFiles(root string, filter Filter) ([]string, error)

SelectedFiles returns what a Copy of the directory root with this filter selects other than directories, as paths from the tree's root. It visits the tree as the copy does, with the copy's own matcher, so the two can't disagree on a pattern. A gitignore filter reads files, so it can't be answered here.

func (*PathTree) SelectedPaths

func (t *PathTree) SelectedPaths(root string, filter Filter) (files, dirs []string, _ error)

SelectedPaths is SelectedFiles, also returning the directories the copy selects itself, which it writes even when it selects nothing in them.

type SelectionOptions

type SelectionOptions struct {
	Source SelectionSource
}

SelectionOptions controls access to a directory selection's source.

type SelectionSource

type SelectionSource interface {
	Open(name string, parent *os.Root) (*os.File, error)
	Children(name string, names []string) ([]string, error)
}

SelectionSource supplies pinned entries from a logical filesystem. Open must confine access and return an O_PATH descriptor without following the final link. A held parent permits a one-component child open. Children adds mountpoints to names read from the pinned directory.

type XAttrErrorHandler

type XAttrErrorHandler func(dst, src, xattrKey string, err error) error

Jump to

Keyboard shortcuts

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