docker

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const STDALL = STDOUT | STDERR

Variables

View Source
var ErrBadHeader = fmt.Errorf("unable to read header")

Functions

This section is empty.

Types

type Client

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

func NewClient

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

func NewClientWithOpts

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

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 int64             `json:"created"`
	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"`
}

type ContainerEvent

type ContainerEvent struct {
	ActorID string `json:"actorId"`
	Action  string `json:"action"`
	Host    string `json:"host"`
}

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, types.EventsOptions) (<-chan events.Message, <-chan error)
	ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
	ContainerStats(ctx context.Context, containerID string, stream bool) (types.ContainerStats, 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
}

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:"-"`
}

func ParseConnection

func ParseConnection(connection string) (Host, error)

type Log

type Log struct {
	StdType    StdType  `json:"type"`
	Timestamp  int64    `json:"ts"`
	Message    any      `json:"m,omitempty"`
	Data       string   `json:"d,omitempty"`
	ActionTags []string `json:"tag,omitempty"`
}

type LogEvent

type LogEvent struct {
	Message   any      `json:"m,omitempty"`
	Timestamp int64    `json:"ts"`
	StdType   string   `json:"t,omitempty"`
	Level     LogLevel `json:"l,omitempty"`
}

type LogLevel

type LogLevel int
const (
	INFO LogLevel = 1 << iota
	DEBUG
	TRACE
	ERROR
	WARN
)

func (LogLevel) EnumIndex

func (l LogLevel) EnumIndex() int

func (LogLevel) String

func (l LogLevel) String() string

type LogReader

type LogReader struct {
	Events chan *LogEvent

	Errors chan error
	// contains filtered or unexported fields
}

func NewLogReader

func NewLogReader(reader io.Reader, tty bool) *LogReader

type StdType

type StdType int
const (
	UNKNOWN StdType = 1 << iota
	STDOUT
	STDERR
)
const (
	Stdin StdType = 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