container

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package container defines a generic interface for managing containerized workloads.

This package allows the lifecycle library to manage containers (Docker, Podman, etc.) without having a direct dependency on their respective SDKs. Consumers can implement the Container interface and pass it to a ContainerWorker for supervision.

key features:

  • **Container Interface**: Generic Start, Stop, Logs, and Status methods.
  • **Mock Implementation**: A reference implementation for testing and local development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container interface {
	// Start initiates the container.
	Start(ctx context.Context) error

	// Stop requests the container to stop gracefully.
	Stop(ctx context.Context) error

	// Inspect returns detailed runtime information.
	Inspect(ctx context.Context) (InspectData, error)

	// Logs returns a reader for the container's logs (stdout/stderr).
	Logs(ctx context.Context) (io.ReadCloser, error)

	// ID returns the unique identifier of the container.
	ID() string

	// Status returns the current lifecycle status.
	Status() Status
}

Container defines a generic interface for managing containerized workloads. This decouples the lifecycle supervisor from specific SDKs like Docker or Podman.

type InspectData

type InspectData struct {
	Image  string
	IP     string
	Ports  []string
	Labels map[string]string
}

InspectData contains detailed runtime information about a container.

type MockContainer

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

MockContainer is a reference/mock implementation of the Container interface.

func NewMockContainer

func NewMockContainer(id string) *MockContainer

func (*MockContainer) ID

func (m *MockContainer) ID() string

func (*MockContainer) Inspect

func (m *MockContainer) Inspect(ctx context.Context) (InspectData, error)

func (*MockContainer) Logs

func (m *MockContainer) Logs(ctx context.Context) (io.ReadCloser, error)

func (*MockContainer) Start

func (m *MockContainer) Start(ctx context.Context) error

func (*MockContainer) Status

func (m *MockContainer) Status() Status

func (*MockContainer) Stop

func (m *MockContainer) Stop(ctx context.Context) error

type Status

type Status string

Status represents the lifecycle state of a container.

const (
	StatusPending Status = "Pending"
	StatusRunning Status = "Running"
	StatusStopped Status = "Stopped"
	StatusFailed  Status = "Failed"
)

Jump to

Keyboard shortcuts

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