container

package
v0.0.0-...-4914057 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package container defines types for sub-container events and also defines an interface for container operation handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearContainerHandlerFactories

func ClearContainerHandlerFactories()

Clear the known factories.

func DebugInfo

func DebugInfo() map[string][]string

func HasFactories

func HasFactories() bool

Returns whether there are any container handler factories registered.

func RegisterContainerHandlerFactory

func RegisterContainerHandlerFactory(factory ContainerHandlerFactory)

Register a ContainerHandlerFactory. These should be registered from least general to most general as they will be asked in order whether they can handle a particular container.

Types

type ContainerHandler

type ContainerHandler interface {
	// Returns the ContainerReference
	ContainerReference() (info.ContainerReference, error)

	// Returns container's isolation spec.
	GetSpec() (info.ContainerSpec, error)

	// Returns the current stats values of the container.
	GetStats() (*info.ContainerStats, error)

	// Returns the subcontainers of this container.
	ListContainers(listType ListType) ([]info.ContainerReference, error)

	// Returns the threads inside this container.
	ListThreads(listType ListType) ([]int, error)

	// Returns the processes inside this container.
	ListProcesses(listType ListType) ([]int, error)

	// Registers a channel to listen for events affecting subcontainers (recursively).
	WatchSubcontainers(events chan SubcontainerEvent) error

	// Stops watching for subcontainer changes.
	StopWatchingSubcontainers() error

	// Returns absolute cgroup path for the requested resource.
	GetCgroupPath(resource string) (string, error)

	// Returns container labels, if available.
	GetContainerLabels() map[string]string

	// Returns whether the container still exists.
	Exists() bool
}

Interface for container operation handlers.

func NewContainerHandler

func NewContainerHandler(name string, inHostNamespace bool) (ContainerHandler, bool, error)

Create a new ContainerHandler for the specified container.

type ContainerHandlerFactory

type ContainerHandlerFactory interface {
	// Create a new ContainerHandler using this factory. CanHandleAndAccept() must have returned true.
	NewContainerHandler(name string, inHostNamespace bool) (c ContainerHandler, err error)

	// Returns whether this factory can handle and accept the specified container.
	CanHandleAndAccept(name string) (handle bool, accept bool, err error)

	// Name of the factory.
	String() string

	// Returns debugging information. Map of lines per category.
	DebugInfo() map[string][]string
}

type FactoryForMockContainerHandler

type FactoryForMockContainerHandler struct {
	Name                        string
	PrepareContainerHandlerFunc func(name string, handler *MockContainerHandler)
}

func (*FactoryForMockContainerHandler) CanHandle

func (self *FactoryForMockContainerHandler) CanHandle(name string) bool

func (*FactoryForMockContainerHandler) NewContainerHandler

func (self *FactoryForMockContainerHandler) NewContainerHandler(name string, inHostNamespace bool) (ContainerHandler, error)

func (*FactoryForMockContainerHandler) String

func (self *FactoryForMockContainerHandler) String() string

type ListType

type ListType int

ListType describes whether listing should be just for a specific container or performed recursively.

const (
	ListSelf ListType = iota
	ListRecursive
)

type MockContainerHandler

type MockContainerHandler struct {
	mock.Mock
	Name    string
	Aliases []string
}

This struct mocks a container handler.

func NewMockContainerHandler

func NewMockContainerHandler(containerName string) *MockContainerHandler

func (*MockContainerHandler) ContainerReference

func (self *MockContainerHandler) ContainerReference() (info.ContainerReference, error)

If self.Name is not empty, then ContainerReference() will return self.Name and self.Aliases. Otherwise, it will use the value provided by .On().Return().

func (*MockContainerHandler) Exists

func (self *MockContainerHandler) Exists() bool

func (*MockContainerHandler) GetCgroupPath

func (self *MockContainerHandler) GetCgroupPath(path string) (string, error)

func (*MockContainerHandler) GetContainerLabels

func (self *MockContainerHandler) GetContainerLabels() map[string]string

func (*MockContainerHandler) GetSpec

func (self *MockContainerHandler) GetSpec() (info.ContainerSpec, error)

func (*MockContainerHandler) GetStats

func (self *MockContainerHandler) GetStats() (*info.ContainerStats, error)

func (*MockContainerHandler) ListContainers

func (self *MockContainerHandler) ListContainers(listType ListType) ([]info.ContainerReference, error)

func (*MockContainerHandler) ListProcesses

func (self *MockContainerHandler) ListProcesses(listType ListType) ([]int, error)

func (*MockContainerHandler) ListThreads

func (self *MockContainerHandler) ListThreads(listType ListType) ([]int, error)

func (*MockContainerHandler) StopWatchingSubcontainers

func (self *MockContainerHandler) StopWatchingSubcontainers() error

func (*MockContainerHandler) WatchSubcontainers

func (self *MockContainerHandler) WatchSubcontainers(events chan SubcontainerEvent) error

type SubcontainerEvent

type SubcontainerEvent struct {
	// The type of event that occurred.
	EventType SubcontainerEventType

	// The full container name of the container where the event occurred.
	Name string
}

SubcontainerEvent represents a

type SubcontainerEventType

type SubcontainerEventType int

SubcontainerEventType indicates an addition or deletion event.

const (
	SubcontainerAdd SubcontainerEventType = iota
	SubcontainerDelete
)

Directories

Path Synopsis
Handler for Docker containers.
Handler for Docker containers.
Unmarshal's a Containers description json file.
Unmarshal's a Containers description json file.

Jump to

Keyboard shortcuts

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