Documentation
¶
Index ¶
- Constants
- Variables
- type Adapter
- func (a *Adapter) CallMethod(ctx context.Context, method Method, request json.RawMessage) (any, error)
- func (a *Adapter) CallOperationMethod(ctx context.Context, operationID string, method Method, ...) (any, error)
- func (a *Adapter) CancelOperation(_ context.Context, req ContainerOperationCancelRequest) (ContainerOperationCancelResult, error)
- func (a *Adapter) FollowLogs(ctx context.Context, req LogsTailRequest, sink LogLineSink) error
- func (a *Adapter) Inspect(ctx context.Context, req ContainerInspectRequest) (ContainerInspectResponse, error)
- func (a *Adapter) List(ctx context.Context, req ContainerListRequest) (ContainerListResponse, error)
- func (a *Adapter) PullImage(ctx context.Context, req ImagePullRequest) (ImagePullResponse, error)
- func (a *Adapter) PullImageWithOperation(ctx context.Context, operationID string, req ImagePullRequest) (ImagePullResponse, error)
- func (a *Adapter) Remove(ctx context.Context, req ContainerActionRequest) (ContainerActionResponse, error)
- func (a *Adapter) RemoveWithOperation(ctx context.Context, operationID string, req ContainerActionRequest) (ContainerActionResponse, error)
- func (a *Adapter) Restart(ctx context.Context, req ContainerActionRequest) (ContainerActionResponse, error)
- func (a *Adapter) RestartWithOperation(ctx context.Context, operationID string, req ContainerActionRequest) (ContainerActionResponse, error)
- func (a *Adapter) Start(ctx context.Context, req ContainerStartRequest) (ContainerActionResponse, error)
- func (a *Adapter) StartPreflight(ctx context.Context, req ContainerStartRequest) (StartPreflightPlan, error)
- func (a *Adapter) StartWithOperation(ctx context.Context, operationID string, req ContainerStartRequest) (ContainerActionResponse, error)
- func (a *Adapter) Status(ctx context.Context, req StatusRequest) (StatusResponse, error)
- func (a *Adapter) Stop(ctx context.Context, req ContainerActionRequest) (ContainerActionResponse, error)
- func (a *Adapter) StopWithOperation(ctx context.Context, operationID string, req ContainerActionRequest) (ContainerActionResponse, error)
- func (a *Adapter) TailLogs(ctx context.Context, req LogsTailRequest) (LogsTailResponse, error)
- type CLIClient
- func (c *CLIClient) Action(ctx context.Context, req EngineActionRequest) (EngineActionResult, error)
- func (c *CLIClient) FollowLogs(ctx context.Context, req EngineLogsRequest, sink LogLineSink) error
- func (c *CLIClient) Inspect(ctx context.Context, engine Engine, containerID string) (EngineContainer, error)
- func (c *CLIClient) List(ctx context.Context, engine Engine, all bool) ([]EngineContainer, error)
- func (c *CLIClient) PullImage(ctx context.Context, engine Engine, imageRef string) (EngineImageResult, error)
- func (c *CLIClient) Status(ctx context.Context, engine Engine) (EngineStatus, error)
- func (c *CLIClient) TailLogs(ctx context.Context, req EngineLogsRequest) (EngineLogsResult, error)
- type CommandRunner
- type CommandRunnerFunc
- type CommandStreamer
- type ContainerActionRequest
- type ContainerActionResponse
- type ContainerInspect
- type ContainerInspectRequest
- type ContainerInspectResponse
- type ContainerListRequest
- type ContainerListResponse
- type ContainerOperationCancelRequest
- type ContainerOperationCancelResult
- type ContainerStartRequest
- type ContainerState
- type ContainerSummary
- type DeviceInput
- type DeviceSummary
- type Engine
- type EngineActionRequest
- type EngineActionResult
- type EngineClient
- type EngineContainer
- type EngineImageResult
- type EngineLogFollower
- type EngineLogsRequest
- type EngineLogsResult
- type EngineStatus
- type EnvSummary
- type ImageInput
- type ImagePullRequest
- type ImagePullResponse
- type ImageSummary
- type LabelSummary
- type LogLine
- type LogLineChannelSink
- type LogLineSink
- type LogLineSinkFunc
- type LogsTailRequest
- type LogsTailResponse
- type Method
- type MountInput
- type MountSourceKind
- type MountSummary
- type MountType
- type PortSummary
- type RiskFlag
- type RiskLevel
- type RiskSeverity
- type RuntimeInput
- type RuntimeSummary
- type StartPreflightInput
- type StartPreflightPlan
- type StatusRequest
- type StatusResponse
- type TargetSummary
Constants ¶
View Source
const ( SchemaVersion = "redeven.capability.container_resources.v1" CapabilityID = "redeven.capability.container_resources" CapabilityVersion = "1.0.0" )
Variables ¶
View Source
var ( ErrInvalidEngine = errors.New("container engine is invalid") ErrInvalidMethod = errors.New("container method is invalid") ErrLogStreamBackpressure = errors.New("logs stream sink backpressure") ErrLogsFollowUnsupported = errors.New("logs follow requires a streaming adapter") ErrContainerOperationIDMissing = errors.New("container operation_id is required") ErrContainerOperationActive = errors.New("container operation is already active") ErrContainerOperationNotFound = errors.New("container operation is not active") ErrContainerOperationMismatch = errors.New("container operation method mismatch") )
View Source
var ErrInvalidSchemaVersion = errors.New("container schema_version is invalid")
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func NewAdapter ¶
func NewAdapter(client EngineClient) *Adapter
func (*Adapter) CallMethod ¶
func (*Adapter) CallOperationMethod ¶
func (*Adapter) CancelOperation ¶
func (a *Adapter) CancelOperation(_ context.Context, req ContainerOperationCancelRequest) (ContainerOperationCancelResult, error)
func (*Adapter) FollowLogs ¶
func (a *Adapter) FollowLogs(ctx context.Context, req LogsTailRequest, sink LogLineSink) error
func (*Adapter) Inspect ¶
func (a *Adapter) Inspect(ctx context.Context, req ContainerInspectRequest) (ContainerInspectResponse, error)
func (*Adapter) List ¶
func (a *Adapter) List(ctx context.Context, req ContainerListRequest) (ContainerListResponse, error)
func (*Adapter) PullImage ¶
func (a *Adapter) PullImage(ctx context.Context, req ImagePullRequest) (ImagePullResponse, error)
func (*Adapter) PullImageWithOperation ¶
func (a *Adapter) PullImageWithOperation(ctx context.Context, operationID string, req ImagePullRequest) (ImagePullResponse, error)
func (*Adapter) Remove ¶
func (a *Adapter) Remove(ctx context.Context, req ContainerActionRequest) (ContainerActionResponse, error)
func (*Adapter) RemoveWithOperation ¶
func (a *Adapter) RemoveWithOperation(ctx context.Context, operationID string, req ContainerActionRequest) (ContainerActionResponse, error)
func (*Adapter) Restart ¶
func (a *Adapter) Restart(ctx context.Context, req ContainerActionRequest) (ContainerActionResponse, error)
func (*Adapter) RestartWithOperation ¶
func (a *Adapter) RestartWithOperation(ctx context.Context, operationID string, req ContainerActionRequest) (ContainerActionResponse, error)
func (*Adapter) Start ¶
func (a *Adapter) Start(ctx context.Context, req ContainerStartRequest) (ContainerActionResponse, error)
func (*Adapter) StartPreflight ¶
func (a *Adapter) StartPreflight(ctx context.Context, req ContainerStartRequest) (StartPreflightPlan, error)
func (*Adapter) StartWithOperation ¶
func (a *Adapter) StartWithOperation(ctx context.Context, operationID string, req ContainerStartRequest) (ContainerActionResponse, error)
func (*Adapter) Status ¶
func (a *Adapter) Status(ctx context.Context, req StatusRequest) (StatusResponse, error)
func (*Adapter) Stop ¶
func (a *Adapter) Stop(ctx context.Context, req ContainerActionRequest) (ContainerActionResponse, error)
func (*Adapter) StopWithOperation ¶
func (a *Adapter) StopWithOperation(ctx context.Context, operationID string, req ContainerActionRequest) (ContainerActionResponse, error)
func (*Adapter) TailLogs ¶
func (a *Adapter) TailLogs(ctx context.Context, req LogsTailRequest) (LogsTailResponse, error)
type CLIClient ¶
type CLIClient struct {
Runner CommandRunner
Timeout time.Duration
StreamTimeout time.Duration
}
func NewCLIClient ¶
func NewCLIClient() *CLIClient
func (*CLIClient) Action ¶
func (c *CLIClient) Action(ctx context.Context, req EngineActionRequest) (EngineActionResult, error)
func (*CLIClient) FollowLogs ¶
func (c *CLIClient) FollowLogs(ctx context.Context, req EngineLogsRequest, sink LogLineSink) error
func (*CLIClient) TailLogs ¶
func (c *CLIClient) TailLogs(ctx context.Context, req EngineLogsRequest) (EngineLogsResult, error)
type CommandRunner ¶
type CommandRunnerFunc ¶
type CommandStreamer ¶
type ContainerActionRequest ¶
type ContainerActionResponse ¶
type ContainerActionResponse struct {
SchemaVersion string `json:"schema_version"`
CapabilityID string `json:"capability_id"`
CapabilityVersion string `json:"capability_version"`
Engine Engine `json:"engine"`
Method Method `json:"method"`
ContainerID string `json:"container_id"`
Completed bool `json:"completed"`
}
type ContainerInspect ¶
type ContainerInspect struct {
ContainerID string `json:"container_id"`
Name string `json:"name,omitempty"`
Image ImageSummary `json:"image"`
State ContainerState `json:"state"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms,omitempty"`
Runtime RuntimeSummary `json:"runtime"`
Labels LabelSummary `json:"labels"`
Ports []PortSummary `json:"ports,omitempty"`
Mounts []MountSummary `json:"mounts,omitempty"`
Devices []DeviceSummary `json:"devices,omitempty"`
}
type ContainerInspectRequest ¶
type ContainerInspectResponse ¶
type ContainerInspectResponse struct {
SchemaVersion string `json:"schema_version"`
CapabilityID string `json:"capability_id"`
Engine Engine `json:"engine"`
Container ContainerInspect `json:"container"`
}
type ContainerListRequest ¶
type ContainerListResponse ¶
type ContainerListResponse struct {
SchemaVersion string `json:"schema_version"`
CapabilityID string `json:"capability_id"`
Engine Engine `json:"engine"`
Containers []ContainerSummary `json:"containers"`
}
type ContainerStartRequest ¶
type ContainerStartRequest struct {
SchemaVersion string `json:"schema_version"`
Engine Engine `json:"engine"`
ContainerID string `json:"container_id"`
}
func NewStartRequest ¶
func NewStartRequest(engine Engine, containerID string) ContainerStartRequest
type ContainerState ¶
type ContainerState string
const ( ContainerStateCreated ContainerState = "created" ContainerStateRunning ContainerState = "running" ContainerStatePaused ContainerState = "paused" ContainerStateRestarting ContainerState = "restarting" ContainerStateExited ContainerState = "exited" ContainerStateStopped ContainerState = "stopped" ContainerStateUnknown ContainerState = "unknown" )
type ContainerSummary ¶
type ContainerSummary struct {
ContainerID string `json:"container_id"`
Name string `json:"name,omitempty"`
Image ImageSummary `json:"image"`
State ContainerState `json:"state"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms,omitempty"`
Ports []PortSummary `json:"ports,omitempty"`
}
type DeviceInput ¶
type DeviceSummary ¶
type EngineActionRequest ¶
type EngineActionResult ¶
type EngineClient ¶
type EngineClient interface {
Status(ctx context.Context, engine Engine) (EngineStatus, error)
List(ctx context.Context, engine Engine, all bool) ([]EngineContainer, error)
Inspect(ctx context.Context, engine Engine, containerID string) (EngineContainer, error)
Action(ctx context.Context, req EngineActionRequest) (EngineActionResult, error)
TailLogs(ctx context.Context, req EngineLogsRequest) (EngineLogsResult, error)
PullImage(ctx context.Context, engine Engine, imageRef string) (EngineImageResult, error)
}
type EngineContainer ¶
type EngineContainer struct {
Engine Engine
ContainerID string
Name string
Image ImageInput
State ContainerState
CreatedAtUnixMs int64
Runtime RuntimeInput
Ports []PortSummary
}
type EngineImageResult ¶
type EngineImageResult struct {
Engine Engine
Image ImageInput
Completed bool
}
type EngineLogFollower ¶
type EngineLogFollower interface {
FollowLogs(ctx context.Context, req EngineLogsRequest, sink LogLineSink) error
}
type EngineLogsRequest ¶
type EngineLogsResult ¶
type EngineStatus ¶
type EnvSummary ¶
type ImageInput ¶
type ImagePullRequest ¶
type ImagePullResponse ¶
type ImageSummary ¶
type LabelSummary ¶
type LogLineChannelSink ¶
type LogLineChannelSink struct {
Lines chan<- LogLine
}
func NewLogLineChannelSink ¶
func NewLogLineChannelSink(lines chan<- LogLine) LogLineChannelSink
func (LogLineChannelSink) AppendLogLine ¶
func (s LogLineChannelSink) AppendLogLine(ctx context.Context, line LogLine) error
type LogLineSink ¶
type LogLineSinkFunc ¶
func (LogLineSinkFunc) AppendLogLine ¶
func (f LogLineSinkFunc) AppendLogLine(ctx context.Context, line LogLine) error
type LogsTailRequest ¶
type LogsTailResponse ¶
type Method ¶
type Method string
const ( MethodStatus Method = "containers.status" MethodList Method = "containers.list" MethodInspect Method = "containers.inspect" MethodStartPreflight Method = "containers.start.preflight" MethodStart Method = "containers.start" MethodStop Method = "containers.stop" MethodRestart Method = "containers.restart" MethodRemove Method = "containers.remove" MethodLogsTail Method = "containers.logs.tail" MethodImagesPull Method = "images.pull" )
type MountInput ¶
type MountSourceKind ¶
type MountSourceKind string
const ( MountSourceHostPath MountSourceKind = "host_path" MountSourceNamedVolume MountSourceKind = "named_volume" MountSourceTmpfs MountSourceKind = "tmpfs" MountSourceContainerSocket MountSourceKind = "container_socket" MountSourceUnknown MountSourceKind = "unknown" )
type MountSummary ¶
type MountSummary struct {
Type MountType `json:"type"`
Source string `json:"source,omitempty"`
Target string `json:"target,omitempty"`
SourceKind MountSourceKind `json:"source_kind"`
ReadOnly bool `json:"read_only"`
SensitivePath bool `json:"sensitive_path,omitempty"`
ContainerSocket bool `json:"container_socket,omitempty"`
}
type PortSummary ¶
type RiskFlag ¶
type RiskFlag struct {
ID string `json:"id"`
Severity RiskSeverity `json:"severity"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
AdminRequired bool `json:"admin_required,omitempty"`
}
type RiskSeverity ¶
type RiskSeverity string
const ( RiskSeverityLow RiskSeverity = "low" RiskSeverityMedium RiskSeverity = "medium" RiskSeverityHigh RiskSeverity = "high" RiskSeverityCritical RiskSeverity = "critical" )
type RuntimeInput ¶
type RuntimeSummary ¶
type RuntimeSummary struct {
Privileged bool `json:"privileged"`
NetworkMode string `json:"network_mode,omitempty"`
PIDMode string `json:"pid_mode,omitempty"`
IPCMode string `json:"ipc_mode,omitempty"`
RestartPolicy string `json:"restart_policy,omitempty"`
Env EnvSummary `json:"env"`
Labels LabelSummary `json:"labels"`
Mounts []MountSummary `json:"mounts,omitempty"`
Devices []DeviceSummary `json:"devices,omitempty"`
CapAdd []string `json:"cap_add,omitempty"`
CapDrop []string `json:"cap_drop,omitempty"`
}
type StartPreflightInput ¶
type StartPreflightInput struct {
Engine Engine
ContainerID string
ContainerName string
Image ImageInput
Runtime RuntimeInput
}
type StartPreflightPlan ¶
type StartPreflightPlan struct {
SchemaVersion string `json:"schema_version"`
CapabilityID string `json:"capability_id"`
CapabilityVersion string `json:"capability_version"`
Method Method `json:"method"`
Request ContainerStartRequest `json:"request"`
Target TargetSummary `json:"target"`
Image ImageSummary `json:"image"`
Runtime RuntimeSummary `json:"runtime"`
RiskLevel RiskLevel `json:"risk_level"`
RiskFlags []RiskFlag `json:"risk_flags"`
RequiresAdmin bool `json:"requires_admin"`
Summary []string `json:"summary,omitempty"`
}
func BuildStartPreflightPlan ¶
func BuildStartPreflightPlan(input StartPreflightInput) (StartPreflightPlan, error)
type StatusRequest ¶
type StatusResponse ¶
Click to show internal directories.
Click to hide internal directories.