trireme-lib: Index | Files | Directories

package dockermonitor

import ""


Package Files

config.go helpers.go monitor.go types.go

type Config Uses

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

Config is the configuration options to start a CNI monitor

func DefaultConfig Uses

func DefaultConfig() *Config

DefaultConfig provides a default configuration

func SetupDefaultConfig Uses

func SetupDefaultConfig(dockerConfig *Config) *Config

SetupDefaultConfig adds defaults to a partial configuration

type DockerClientInterface Uses

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 Uses

type DockerMonitor struct {
    // contains filtered or unexported fields

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

func New Uses

func New() *DockerMonitor

New returns a new docker monitor.

func (*DockerMonitor) Resync Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

A EventHandler is type of docker event handler functions.


mockdockerPackage mockdocker is a generated GoMock package.

Package dockermonitor imports 24 packages (graph) and is imported by 4 packages. Updated 2019-09-05. Refresh now. Tools for package owners.