instance

package
v3.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OciSubDir represents directory where OCI instance files are stored
	OciSubDir = "oci"
	// SingSubDir represents directory where Singularity instance files are stored
	SingSubDir = "sing"
)
View Source
const (
	// BasicLogFormat represents basic log format.
	BasicLogFormat = "basic"
	// KubernetesLogFormat represents kubernetes log format.
	KubernetesLogFormat = "kubernetes"
	// JSONLogFormat represents JSON log format.
	JSONLogFormat = "json"
)

Variables

View Source
var LogFormats = map[string]LogFormatter{
	BasicLogFormat:      basicLogFormatter,
	KubernetesLogFormat: kubernetesLogFormatter,
	JSONLogFormat:       jsonLogFormatter,
}

LogFormats contains supported log format by default.

Functions

func CheckName

func CheckName(name string) error

CheckName checks if name is a valid instance name

func ExtractName

func ExtractName(name string) string

ExtractName extracts instance name from an instance:// URI

func GetDirPrivileged

func GetDirPrivileged(name string, subDir string) (string, error)

GetDirPrivileged returns directory where instances file will be stored if instance is run with privileges

func GetDirUnprivileged

func GetDirUnprivileged(name string, subDir string) (string, error)

GetDirUnprivileged returns directory where instances file will be stored if instance is run without privileges

func ProcName

func ProcName(name string, username string) string

ProcName returns processus name based on instance name and username

func SetLogFile

func SetLogFile(name string, uid int, subDir string) (*os.File, *os.File, error)

SetLogFile replaces stdout/stderr streams and redirect content to log file

Types

type File

type File struct {
	Path       string `json:"-"`
	Pid        int    `json:"pid"`
	PPid       int    `json:"ppid"`
	Name       string `json:"name"`
	User       string `json:"user"`
	Image      string `json:"image"`
	Privileged bool   `json:"privileged"`
	Config     []byte `json:"config"`
}

File represents an instance file storing instance information

func Add

func Add(name string, privileged bool, subDir string) (*File, error)

Add creates an instance file for a named instance in a privileged or unprivileged path

func Get

func Get(name string, subDir string) (*File, error)

Get returns the instance file corresponding to instance name

func List

func List(username string, name string, subDir string) ([]*File, error)

List returns instance files matching username and/or name pattern

func (*File) Delete

func (i *File) Delete() error

Delete deletes instance file

func (*File) MountNamespaces

func (i *File) MountNamespaces() error

MountNamespaces binds /proc/<pid>/ns directory into instance folder

func (*File) PrivilegedPath

func (i *File) PrivilegedPath() bool

PrivilegedPath returns if instance file is stored in privileged path or not

func (*File) Update

func (i *File) Update() error

Update stores instance information in associated instance file

func (*File) UpdateNamespacesPath

func (i *File) UpdateNamespacesPath(configNs []specs.LinuxNamespace) error

UpdateNamespacesPath updates namespaces path for the provided configuration

type LogFormatter

type LogFormatter func(stream string, data string) string

LogFormatter implements a log formatter.

type Logger

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

Logger defines a file logger.

func NewLogger

func NewLogger(logPath string, formatter LogFormatter) (*Logger, error)

NewLogger instantiates a new logger with formatter and return it.

func (*Logger) NewWriter

func (l *Logger) NewWriter(stream string, dropCRNL bool) *io.PipeWriter

NewWriter create a new pipe pair for corresponding stream.

func (*Logger) ReOpenFile

func (l *Logger) ReOpenFile()

ReOpenFile closes and re-open log file (eg: log rotation).

Jump to

Keyboard shortcuts

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