allocdir

package
v0.3.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2016 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Functions shared between linux/darwin.

Index

Constants

This section is empty.

Variables

View Source
var (
	// The name of the directory that is shared across tasks in a task group.
	SharedAllocName = "alloc"

	// Name of the directory where logs of Tasks are written
	LogDirName = "logs"

	// The set of directories that exist inside eache shared alloc directory.
	SharedAllocDirs = []string{LogDirName, "tmp", "data"}

	// The name of the directory that exists inside each task directory
	// regardless of driver.
	TaskLocal = "local"

	// TaskDirs is the set of directories created in each tasks directory.
	TaskDirs = []string{"tmp"}
)

Functions

This section is empty.

Types

type AllocDir

type AllocDir struct {
	// AllocDir is the directory used for storing any state
	// of this allocation. It will be purged on alloc destroy.
	AllocDir string

	// The shared directory is available to all tasks within the same task
	// group.
	SharedDir string

	// TaskDirs is a mapping of task names to their non-shared directory.
	TaskDirs map[string]string
}

func NewAllocDir

func NewAllocDir(allocDir string) *AllocDir

func (*AllocDir) Build

func (d *AllocDir) Build(tasks []*structs.Task) error

Given a list of a task build the correct alloc structure.

func (*AllocDir) Destroy

func (d *AllocDir) Destroy() error

Tears down previously build directory structure.

func (*AllocDir) Embed

func (d *AllocDir) Embed(task string, entries map[string]string) error

Embed takes a mapping of absolute directory or file paths on the host to their intended, relative location within the task directory. Embed attempts hardlink and then defaults to copying. If the path exists on the host and can't be embeded an error is returned.

func (*AllocDir) List added in v0.3.0

func (d *AllocDir) List(path string) ([]*AllocFileInfo, error)

List returns the list of files at a path relative to the alloc dir

func (*AllocDir) LogDir added in v0.3.0

func (d *AllocDir) LogDir() string

LogDir returns the log dir in the current allocation directory

func (*AllocDir) MountSharedDir

func (d *AllocDir) MountSharedDir(task string) error

MountSharedDir mounts the shared directory into the specified task's directory. Mount is documented at an OS level in their respective implementation files.

func (*AllocDir) MountSpecialDirs added in v0.3.0

func (d *AllocDir) MountSpecialDirs(taskDir string) error

MountSpecialDirs mounts the dev and proc file system from the host to the chroot

func (*AllocDir) ReadAt added in v0.3.0

func (d *AllocDir) ReadAt(path string, offset int64, limit int64) (io.ReadCloser, error)

ReadAt returns a reader for a file at the path relative to the alloc dir which will read a chunk of bytes at a particular offset

func (*AllocDir) Stat added in v0.3.0

func (d *AllocDir) Stat(path string) (*AllocFileInfo, error)

Stat returns information about the file at a path relative to the alloc dir

func (*AllocDir) UnmountAll added in v0.3.0

func (d *AllocDir) UnmountAll() error

type AllocDirFS added in v0.3.0

type AllocDirFS interface {
	List(path string) ([]*AllocFileInfo, error)
	Stat(path string) (*AllocFileInfo, error)
	ReadAt(path string, offset int64, limit int64) (io.ReadCloser, error)
}

AllocDirFS exposes file operations on the alloc dir

type AllocFileInfo added in v0.3.0

type AllocFileInfo struct {
	Name     string
	IsDir    bool
	Size     int64
	FileMode string
	ModTime  time.Time
}

AllocFileInfo holds information about a file inside the AllocDir

type ReadCloserWrapper added in v0.3.0

type ReadCloserWrapper struct {
	io.Reader
	io.Closer
}

ReadCloserWrapper wraps a LimitReader so that a file is closed once it has been read

Jump to

Keyboard shortcuts

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