dockermonitor

package
v10.173.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	EventMetadataExtractor     extractors.DockerMetadataExtractor
	SocketType                 string
	SocketAddress              string
	SyncAtStart                bool
	KillContainerOnPolicyError bool
}

Config is the configuration options to start a CNI monitor

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig provides a default configuration

func SetupDefaultConfig

func SetupDefaultConfig(dockerConfig *Config) *Config

SetupDefaultConfig adds defaults to a partial configuration

type DockerClientInterface

type DockerClientInterface interface {
	// ContainerInspect corresponds to the ContainerInspect of docker.
	ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)

	// ContainerList abstracts the ContainerList as interface.
	ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)

	// ContainerStop abstracts the ContainerStop as interface.
	ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error

	// Events abstracts the Event method as an interface.
	Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)

	// Ping abstracts the Event method as an interface
	Ping(ctx context.Context) (types.Ping, error)
}

DockerClientInterface creates an interface for the docker client so that we can do tests.

type DockerMonitor

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

DockerMonitor implements the connection to Docker and monitoring based on docker events.

func New

func New() *DockerMonitor

New returns a new docker monitor.

func (*DockerMonitor) Resync

func (d *DockerMonitor) Resync(ctx context.Context) error

Resync resyncs all the existing containers on the Host, using the same process as when a container is initially spawn up

func (*DockerMonitor) Run

func (d *DockerMonitor) Run(ctx context.Context) error

Run will start the DockerPolicy Enforcement. It applies a policy to each Container already Up and Running. It listens to all ContainerEvents

func (*DockerMonitor) SetupConfig

func (d *DockerMonitor) SetupConfig(registerer registerer.Registerer, cfg interface{}) (err error)

SetupConfig provides a configuration to implmentations. Every implementation can have its own config type.

func (*DockerMonitor) SetupHandlers

func (d *DockerMonitor) SetupHandlers(c *config.ProcessorConfig)

SetupHandlers sets up handlers for monitors to invoke for various events such as processing unit events and synchronization events. This will be called before Start() by the consumer of the monitor

type Event

type Event string

Event is the type of various docker events.

const (
	// EventCreate represents the Docker "create" event.
	EventCreate Event = "create"

	// EventStart represents the Docker "start" event.
	EventStart Event = "start"

	// EventDie represents the Docker "die" event.
	EventDie Event = "die"

	// EventDestroy represents the Docker "destroy" event.
	EventDestroy Event = "destroy"

	// EventPause represents the Docker "pause" event.
	EventPause Event = "pause"

	// EventUnpause represents the Docker "unpause" event.
	EventUnpause Event = "unpause"

	// EventConnect represents the Docker "connect" event.
	EventConnect Event = "connect"

	// DockerClientVersion is the version sent out as the client
	DockerClientVersion = "v1.23"
)

type EventHandler

type EventHandler func(ctx context.Context, event *events.Message) error

A EventHandler is type of docker event handler functions.

Directories

Path Synopsis
Package mockdocker is a generated GoMock package.
Package mockdocker is a generated GoMock package.

Jump to

Keyboard shortcuts

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