mgr

package
v0.0.0-...-e6e6c42 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2017 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachConfig

type AttachConfig struct {
	Hijack  http.Hijacker
	Stdin   bool
	Stdout  bool
	Stderr  bool
	Upgrade bool
}

AttachConfig wraps some infos of attaching.

type Container

type Container struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Container represents the container instance in runtime.

func (*Container) ID

func (c *Container) ID() string

ID returns container's id.

func (*Container) IsCreated

func (c *Container) IsCreated() bool

IsCreated returns container is created or not.

func (*Container) IsRunning

func (c *Container) IsRunning() bool

IsRunning returns container is running or not.

func (*Container) IsStopped

func (c *Container) IsStopped() bool

IsStopped returns container is stopped or not.

func (*Container) Name

func (c *Container) Name() string

Name returns container's name.

func (*Container) Write

func (c *Container) Write(store *meta.Store) error

Write writes container's meta data into meta store.

type ContainerManager

type ContainerManager struct {
	Store         *meta.Store
	Client        *ctrd.Client
	NameToID      *collect.SafeMap
	ImageMgr      ImageMgr
	VolumeMgr     VolumeMgr
	IOs           *containerio.Cache
	ExecProcesses *collect.SafeMap
	Config        *config.Config
	// contains filtered or unexported fields
}

ContainerManager is the default implement of interface ContainerMgr.

func NewContainerManager

func NewContainerManager(ctx context.Context, store *meta.Store, cli *ctrd.Client, imgMgr ImageMgr, volMgr VolumeMgr, cfg *config.Config) (*ContainerManager, error)

NewContainerManager creates a brand new container manager.

func (*ContainerManager) Attach

func (mgr *ContainerManager) Attach(ctx context.Context, name string, attach *AttachConfig) error

Attach attachs a container's io.

func (*ContainerManager) Create

Create checks passed in parameters and create a Container object whose status is set at Created.

func (*ContainerManager) CreateExec

func (mgr *ContainerManager) CreateExec(ctx context.Context, name string, config *types.ExecCreateConfig) (string, error)

CreateExec creates exec process's meta data.

func (*ContainerManager) Get

func (mgr *ContainerManager) Get(name string) (*types.ContainerInfo, error)

Get the detailed information of container

func (*ContainerManager) List

List returns the container's list.

func (*ContainerManager) Pause

func (mgr *ContainerManager) Pause(ctx context.Context, name string) error

Pause pauses a running container.

func (*ContainerManager) Remove

func (mgr *ContainerManager) Remove(ctx context.Context, name string, option *ContainerRemoveOption) error

Remove removes a container, it may be running or stopped and so on.

func (*ContainerManager) Rename

func (mgr *ContainerManager) Rename(ctx context.Context, oldName, newName string) error

Rename renames a container

func (*ContainerManager) Restore

func (mgr *ContainerManager) Restore(ctx context.Context) error

Restore containers from meta store to memory and recover those container.

func (*ContainerManager) Start

func (mgr *ContainerManager) Start(ctx context.Context, id, detachKeys string) (err error)

Start a pre created Container.

func (*ContainerManager) StartExec

func (mgr *ContainerManager) StartExec(ctx context.Context, execid string, config *types.ExecStartConfig, attach *AttachConfig) error

StartExec executes a new process in container.

func (*ContainerManager) Stop

func (mgr *ContainerManager) Stop(ctx context.Context, name string, timeout time.Duration) error

Stop stops a running container.

type ContainerMgr

type ContainerMgr interface {
	// Create a new container.
	Create(ctx context.Context, name string, config *types.ContainerConfigWrapper) (*types.ContainerCreateResp, error)

	// Start a container.
	Start(ctx context.Context, id, detachKeys string) error

	// Stop a container.
	Stop(ctx context.Context, name string, timeout time.Duration) error

	// Pause a container.
	Pause(ctx context.Context, name string) error

	// Attach a container.
	Attach(ctx context.Context, name string, attach *AttachConfig) error

	// List returns the list of containers.
	List(ctx context.Context) ([]*types.ContainerInfo, error)

	// CreateExec creates exec process's environment.
	CreateExec(ctx context.Context, name string, config *types.ExecCreateConfig) (string, error)

	// StartExec executes a new process in container.
	StartExec(ctx context.Context, execid string, config *types.ExecStartConfig, attach *AttachConfig) error

	// Remove removes a container, it may be running or stopped and so on.
	Remove(ctx context.Context, name string, option *ContainerRemoveOption) error

	// Rename renames a container
	Rename(ctx context.Context, oldName string, newName string) error

	// Get the detailed information of container
	Get(name string) (*types.ContainerInfo, error)
}

ContainerMgr as an interface defines all operations against container.

type ContainerRemoveOption

type ContainerRemoveOption struct {
	Force  bool
	Volume bool
	Link   bool
}

ContainerRemoveOption wraps the container remove interface params.

type ImageManager

type ImageManager struct {
	// DefaultRegistry is the default registry of daemon.
	// When users do not specify image repo in image name,
	// daemon will automatically pull images from DefaultRegistry.
	// TODO: make DefaultRegistry can be reloaded.
	DefaultRegistry string
	// contains filtered or unexported fields
}

ImageManager is an implementation of interface ImageMgr. It is a stateless manager, and it will never store image details. When image details needed from users, ImageManager interacts with containerd to get details.

func NewImageManager

func NewImageManager(cfg *config.Config, client *ctrd.Client) (*ImageManager, error)

NewImageManager initializes a brand new image manager.

func (*ImageManager) GetImage

func (mgr *ImageManager) GetImage(ctx context.Context, idOrRef string) (*types.ImageInfo, error)

GetImage gets image by image id or ref.

func (*ImageManager) ListImages

func (mgr *ImageManager) ListImages(ctx context.Context, filters string) ([]types.ImageInfo, error)

ListImages lists images stored by containerd.

func (*ImageManager) PullImage

func (mgr *ImageManager) PullImage(pctx context.Context, image, tag string, out io.Writer) error

PullImage pulls images from specified registry.

func (*ImageManager) RemoveImage

func (mgr *ImageManager) RemoveImage(ctx context.Context, name string, option *ImageRemoveOption) error

RemoveImage deletes an image by reference.

func (*ImageManager) SearchImages

func (mgr *ImageManager) SearchImages(ctx context.Context, name string, registry string) ([]types.SearchResultItem, error)

SearchImages searches imaged from specified registry.

type ImageMgr

type ImageMgr interface {
	// PullImage pulls images from specified registry.
	PullImage(ctx context.Context, image, tag string, out io.Writer) error

	// ListImages lists images stored by containerd.
	ListImages(ctx context.Context, filters string) ([]types.ImageInfo, error)

	// Search Images from specified registry.
	SearchImages(ctx context.Context, name string, registry string) ([]types.SearchResultItem, error)

	// GetImage gets image by image id or ref.
	GetImage(ctx context.Context, idOrRef string) (*types.ImageInfo, error)

	// RemoveImage deletes an image by reference.
	RemoveImage(ctx context.Context, name string, option *ImageRemoveOption) error
}

ImageMgr as an interface defines all operations against images.

type ImageRemoveOption

type ImageRemoveOption struct {
	Force bool
}

ImageRemoveOption wraps the image remove interface params.

type SystemManager

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

SystemManager is an instance of system management.

func NewSystemManager

func NewSystemManager(cfg *config.Config) (*SystemManager, error)

NewSystemManager creates a brand new system manager.

func (*SystemManager) Info

func (mgr *SystemManager) Info() (types.SystemInfo, error)

Info shows system information of daemon.

func (*SystemManager) Version

func (mgr *SystemManager) Version() (types.SystemVersion, error)

Version shows version of daemon.

type SystemMgr

type SystemMgr interface {
	Info() (types.SystemInfo, error)
	Version() (types.SystemVersion, error)
}

SystemMgr as an interface defines all operations against host.

type VolumeManager

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

VolumeManager is the default implement of interface VolumeMgr.

func NewVolumeManager

func NewVolumeManager(ms *meta.Store, cfg volume.Config) (*VolumeManager, error)

NewVolumeManager creates a brand new volume manager.

func (*VolumeManager) Attach

func (vm *VolumeManager) Attach(ctx context.Context, name string, options map[string]string) (*types.Volume, error)

Attach is used to bind a volume to container.

func (*VolumeManager) Create

func (vm *VolumeManager) Create(ctx context.Context, name, driver string, options, labels map[string]string) error

Create is used to create volume.

func (*VolumeManager) Detach

func (vm *VolumeManager) Detach(ctx context.Context, name string, options map[string]string) (*types.Volume, error)

Detach is used to unbind a volume from container.

func (*VolumeManager) Info

func (vm *VolumeManager) Info(ctx context.Context, name string) (*types.Volume, error)

Info returns the information of volume that specified name/id.

func (*VolumeManager) List

func (vm *VolumeManager) List(ctx context.Context, labels map[string]string) ([]string, error)

List returns all volumes on this host.

func (*VolumeManager) Path

func (vm *VolumeManager) Path(ctx context.Context, name string) (string, error)

Path returns the mount path of volume.

func (*VolumeManager) Remove

func (vm *VolumeManager) Remove(ctx context.Context, name string) error

Remove is used to delete an existing volume.

type VolumeMgr

type VolumeMgr interface {
	// Create is used to create volume.
	Create(ctx context.Context, name, driver string, options, labels map[string]string) error

	// Remove is used to delete an existing volume.
	Remove(ctx context.Context, name string) error

	// List returns all volumes on this host.
	List(ctx context.Context, labels map[string]string) ([]string, error)

	// Info returns the information of volume that specified name/id.
	Info(ctx context.Context, name string) (*types.Volume, error)

	// Path returns the mount path of volume.
	Path(ctx context.Context, name string) (string, error)

	// Attach is used to bind a volume to container.
	Attach(ctx context.Context, name string, options map[string]string) (*types.Volume, error)

	// Detach is used to unbind a volume from container.
	Detach(ctx context.Context, name string, options map[string]string) (*types.Volume, error)
}

VolumeMgr defines interface to manage container volume.

Jump to

Keyboard shortcuts

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