Files
2026-01-22 16:54:53 -08:00

62 lines
1.5 KiB
Go

package container
import (
"context"
"io"
"time"
)
type StdType int
const (
UNKNOWN StdType = 1 << iota
STDOUT
STDERR
)
const STDALL = STDOUT | STDERR
func (s StdType) String() string {
switch s {
case STDOUT:
return "stdout"
case STDERR:
return "stderr"
case STDALL:
return "all"
default:
return "unknown"
}
}
type ExecSession struct {
Writer io.WriteCloser
Reader io.Reader
Resize func(width uint, height uint) error
}
type ExecEvent struct {
Type string `json:"type"`
Data string `json:"data,omitempty"`
Width uint `json:"width,omitempty"`
Height uint `json:"height,omitempty"`
}
// ExecEventReader provides structured exec events (userinput, resize)
type ExecEventReader interface {
ReadEvent() (*ExecEvent, error)
}
type Client interface {
ListContainers(context.Context, ContainerLabels) ([]Container, error)
FindContainer(context.Context, string) (Container, error)
ContainerLogs(context.Context, string, time.Time, StdType) (io.ReadCloser, error)
ContainerEvents(context.Context, chan<- ContainerEvent) error
ContainerLogsBetweenDates(context.Context, string, time.Time, time.Time, StdType) (io.ReadCloser, error)
ContainerStats(context.Context, string, chan<- ContainerStat) error
Ping(context.Context) error
Host() Host
ContainerActions(ctx context.Context, action ContainerAction, containerID string) error
ContainerAttach(ctx context.Context, id string) (*ExecSession, error)
ContainerExec(ctx context.Context, id string, cmd []string) (*ExecSession, error)
}