Documentation ¶
Index ¶
- Constants
- type Chroot
- func (c *Chroot) AddFiles(filesToCopy ...FileToCopy) (err error)
- func (c *Chroot) Close(leaveOnDisk bool) (err error)
- func (c *Chroot) CopyOutFile(srcPath string, destPath string) (err error)
- func (c *Chroot) Initialize(tarPath string, extraDirectories []string, extraMountPoints []*MountPoint, ...) (err error)
- func (c *Chroot) MoveOutFile(srcPath string, destPath string) (err error)
- func (c *Chroot) RootDir() string
- func (c *Chroot) Run(toRun func() error) (err error)
- func (c *Chroot) UnsafeRun(toRun func() error) (err error)
- type ChrootInterface
- type DummyChroot
- type FileToCopy
- type MountPoint
- func NewMountPoint(source, target, fstype string, flags uintptr, data string) (mountPoint *MountPoint)
- func NewOverlayMountPoint(chrootDir, source, target, lowerDir, upperDir, workDir string) (mountPoint *MountPoint, extaDirsNeeds []string)
- func NewPreDefaultsMountPoint(source, target, fstype string, flags uintptr, data string) (mountPoint *MountPoint)
Constants ¶
const BindMountPointFlags = unix.MS_BIND | unix.MS_MGC_VAL
BindMountPointFlags is a set of flags to do a bind mount.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chroot ¶
type Chroot struct {
// contains filtered or unexported fields
}
Chroot represents a Chroot environment with automatic synchronization protections and guaranteed cleanup code even on SIGTERM so long as registerSIGTERMCleanup is invoked.
func (*Chroot) AddFiles ¶
func (c *Chroot) AddFiles(filesToCopy ...FileToCopy) (err error)
AddFiles copies each file 'Src' to the relative path chrootRootDir/'Dest' in the chroot.
func (*Chroot) Close ¶
Close will unmount the chroot and cleanup its files. This call will block until the chroot cleanup runs. Only one Chroot will close at a given time.
func (*Chroot) CopyOutFile ¶
CopyOutFile copies file 'srcPath' in the chroot to the host at 'destPath'
func (*Chroot) Initialize ¶
func (c *Chroot) Initialize(tarPath string, extraDirectories []string, extraMountPoints []*MountPoint, includeDefaultMounts bool, ) (err error)
Initialize initializes a Chroot, creating directories and mount points.
- tarPath is an optional path to a tar file that will be extracted at the root of the chroot.
- extraDirectories is an optional slice of additional directories that should be created before attempting to mount inside the chroot.
- extraMountPoints is an optional slice of additional mount points that should be created inside the chroot, they will automatically be unmounted on a Chroot Close.
This call will block until the chroot initializes successfully. Only one Chroot will initialize at a given time.
func (*Chroot) MoveOutFile ¶
MoveOutFile moves file 'srcPath' in the chroot to the host at 'destPath', deleting the 'srcPath' file.
type ChrootInterface ¶
type DummyChroot ¶
type DummyChroot struct { }
DummyChroot is a placeholder that implements ChrootInterface.
func (*DummyChroot) AddFiles ¶
func (d *DummyChroot) AddFiles(filesToCopy ...FileToCopy) (err error)
func (*DummyChroot) RootDir ¶
func (d *DummyChroot) RootDir() string
func (*DummyChroot) Run ¶
func (d *DummyChroot) Run(toRun func() error) (err error)
func (*DummyChroot) UnsafeRun ¶
func (d *DummyChroot) UnsafeRun(toRun func() error) (err error)
type FileToCopy ¶
FileToCopy represents a file to copy into a chroot using AddFiles. Dest is relative to the chroot directory.
type MountPoint ¶
type MountPoint struct {
// contains filtered or unexported fields
}
MountPoint represents a system mount point used by a Chroot. It is guaranteed to be unmounted on application exit even on a SIGTERM so long as registerSIGTERMCleanup is invoked. The fields of MountPoint mirror those of the `mount` syscall.
func NewMountPoint ¶
func NewMountPoint(source, target, fstype string, flags uintptr, data string) (mountPoint *MountPoint)
NewMountPoint creates a new MountPoint struct to be created by a Chroot
func NewOverlayMountPoint ¶
func NewOverlayMountPoint(chrootDir, source, target, lowerDir, upperDir, workDir string) (mountPoint *MountPoint, extaDirsNeeds []string)
NewOverlayMountPoint creates a new MountPoint struct and extra directories slice configured for a given overlay
func NewPreDefaultsMountPoint ¶
func NewPreDefaultsMountPoint(source, target, fstype string, flags uintptr, data string) (mountPoint *MountPoint)
NewPreDefaultsMountPoint creates a new MountPoint struct to be created by a Chroot but before the default mount points.