namespace

package
v0.0.0-...-03f4643 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespaceErrorPrefix  string = "err:"
	NamespaceReturnPrefix string = "ret:"
)

Variables

This section is empty.

Functions

func OpenNSFile

func OpenNSFile(t types.NamespaceType, pid int) (*os.File, error)

Types

type Manager

type Manager interface {
	Get(ref types.Reference, extraRefs ...types.Reference) (fd int, info interface{}, err error)
	Put(fd int) error
	Update(ref types.Reference, capacity int) error
	CleanUp() error
}

Manager manages different types of namespace

type NamespaceFunction

type NamespaceFunction func(map[string]interface{}) ([]byte, error)

type NamespaceFunctionKey

type NamespaceFunctionKey string
const (
	NamespaceFunctionKeyCreate  NamespaceFunctionKey = "create"
	NamespaceFunctionKeyRelease NamespaceFunctionKey = "release"
	NamespaceFunctionKeyReset   NamespaceFunctionKey = "reset"
)

type NamespaceHelper

type NamespaceHelper struct {
	Cmd *exec.Cmd
	Ret []byte
	// contains filtered or unexported fields
}

func NewNamespaceExecCreateHelper

func NewNamespaceExecCreateHelper(key NamespaceFunctionKey, nsType types.NamespaceType, args map[string]string) (*NamespaceHelper, error)

func NewNamespaceExecEnterHelper

func NewNamespaceExecEnterHelper(key NamespaceFunctionKey, nsType types.NamespaceType, fdPath string, args map[string]string) (*NamespaceHelper, error)

func (*NamespaceHelper) Do

func (helper *NamespaceHelper) Do(release bool) (err error)

Do executes the command

func (*NamespaceHelper) Release

func (helper *NamespaceHelper) Release() error

Release releases the child process and get the return content from child process

type Set

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

func NewSet

func NewSet(capacity int, namespaceCreator func() (*os.File, error), preReleaseNamespace func(*os.File) error) (*Set, error)

func (*Set) Add

func (s *Set) Add(f *os.File)

func (Set) Capacity

func (s Set) Capacity() int

func (*Set) CleanUp

func (s *Set) CleanUp() error

func (*Set) CreateOne

func (s *Set) CreateOne() error

func (Set) DefaultCapacity

func (s Set) DefaultCapacity() int

func (*Set) Get

func (s *Set) Get() *os.File

func (*Set) Update

func (s *Set) Update(capacity int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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