docker

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const STDALL = STDOUT | STDERR

Variables

View Source
var Action = Actions{
	START:   ActionStart,
	STOP:    ActionStop,
	RESTART: ActionRestart,
	PULL:    ActionPull,
}
View Source
var ParenthesisRe = regexp.MustCompile(`\(([a-zA-Z]+)\)`)

Functions

func CreateClients

func CreateClients(args argsType.Args) map[string]Client

Types

type Actions

type Actions struct {
	START   ContainerAction
	STOP    ContainerAction
	RESTART ContainerAction
	PULL    ContainerAction
}

type Client

type Client interface {
	ListContainers() ([]Container, error)
	FindContainer(string) (Container, error)
	ContainerLogs(context.Context, string, *time.Time, StdType) (io.ReadCloser, error)
	Events(context.Context, chan<- ContainerEvent) error
	ContainerLogsBetweenDates(context.Context, string, time.Time, time.Time, StdType) (io.ReadCloser, error)
	Ping(context.Context) (types.Ping, error)
	Host() *Host
	ContainerActions(action ContainerAction, containerID string) error
	IsSwarmMode() bool
	SystemInfo() system.Info
}

func NewClient

func NewClient(cli DockerCLI, filters filters.Args, host *Host) Client

func NewClientWithFilters

func NewClientWithFilters(f map[string][]string) (Client, error)

NewClientWithFilters creates a new instance of Client with docker filters

func NewClientWithTLSAndFilter

func NewClientWithTLSAndFilter(f map[string][]string, host Host) (Client, error)

NewClientWithTLSAndFilter creates a new instance of Client with docker filters for remote hosts

type Container

type Container struct {
	ID        string            `json:"id"`
	Names     []string          `json:"names"`
	Name      string            `json:"name"`
	Image     string            `json:"image"`
	ImageID   string            `json:"imageId"`
	Command   string            `json:"command"`
	Created   time.Time         `json:"created"`
	StartedAt *time.Time        `json:"startedAt,omitempty"`
	State     string            `json:"state"`
	Status    string            `json:"status"`
	Health    string            `json:"health,omitempty"`
	Host      string            `json:"host,omitempty"`
	Tty       bool              `json:"-"`
	Labels    map[string]string `json:"labels,omitempty"`
}

Container represents an internal representation of docker containers

func (*Container) GetDescription

func (c *Container) GetDescription() string

func (*Container) GetDescriptionFull

func (c *Container) GetDescriptionFull() string

type ContainerAction

type ContainerAction string
const (
	ActionStart   ContainerAction = "start"
	ActionStop    ContainerAction = "stop"
	ActionRestart ContainerAction = "restart"
	ActionPull    ContainerAction = "pull"
)

type ContainerEvent

type ContainerEvent struct {
	ActorID string `json:"actorId"`
	Name    string `json:"name"`
	Host    string `json:"host"`
}

ContainerEvent represents events that are triggered

type ContainerStore

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

func NewContainerStore

func NewContainerStore(ctx context.Context, client Client) *ContainerStore

func (*ContainerStore) Client

func (s *ContainerStore) Client() Client

func (*ContainerStore) List

func (s *ContainerStore) List() ([]Container, error)

func (*ContainerStore) Subscribe

func (s *ContainerStore) Subscribe(ctx context.Context, events chan ContainerEvent)

func (*ContainerStore) SubscribeNewContainers

func (s *ContainerStore) SubscribeNewContainers(ctx context.Context, containers chan Container)

func (*ContainerStore) Unsubscribe

func (s *ContainerStore) Unsubscribe(ctx context.Context)

type DockerCLI

type DockerCLI interface {
	ContainerList(context.Context, container.ListOptions) ([]types.Container, error)
	ContainerLogs(context.Context, string, container.LogsOptions) (io.ReadCloser, error)
	Events(context.Context, events.ListOptions) (<-chan events.Message, <-chan error)
	ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
	ContainerStats(ctx context.Context, containerID string, stream bool) (container.StatsResponse, error)
	Ping(ctx context.Context) (types.Ping, error)
	ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
	ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
	ContainerRestart(ctx context.Context, containerID string, options container.StopOptions) error
	Info(ctx context.Context) (system.Info, error)
	ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error)
	ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)
}

type Host

type Host struct {
	Name       string   `json:"name"`
	ID         string   `json:"id"`
	URL        *url.URL `json:"-"`
	CertPath   string   `json:"-"`
	CACertPath string   `json:"-"`
	KeyPath    string   `json:"-"`
	ValidCerts bool     `json:"-"`
	NCPU       int      `json:"nCPU"`
	MemTotal   int64    `json:"memTotal"`
}

func ParseConnection

func ParseConnection(connection string) (Host, error)

func (*Host) GetDescription

func (h *Host) GetDescription() string

type StdType

type StdType int
const (
	UNKNOWN StdType = 1 << iota
	STDOUT
	STDERR
)

func (StdType) String

func (s StdType) String() string

Jump to

Keyboard shortcuts

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