container

package
v0.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StdOut byte = 1
	StdErr byte = 2
)
View Source
const APIVersion = "1.47"
View Source
const (
	FallbackSocketPath = "/var/run/docker.sock"
)
View Source
const OK = 0

Variables

This section is empty.

Functions

func EnvSocket

func EnvSocket() (string, error)

func GetDaemonSocketPath

func GetDaemonSocketPath() string

func SocketExists

func SocketExists(path string) bool

func SplitOutput

func SplitOutput(src io.Reader) ([]byte, []byte, error)

Types

type APIClient

type APIClient struct {
	Doer    HTTPDoer
	BaseURL string
	Log     *slog.Logger
}

func NewAPIClient

func NewAPIClient() *APIClient

func NewAPIClientWithLogger

func NewAPIClientWithLogger(log *slog.Logger) *APIClient

func (*APIClient) Compatible

func (c *APIClient) Compatible(ctx context.Context) (bool, error)

func (*APIClient) ContainerExists

func (c *APIClient) ContainerExists(ctx context.Context, cID string) (bool, error)

func (*APIClient) Create

func (c *APIClient) Create(
	ctx context.Context,
	cfg Config,
) (string, error)

func (*APIClient) ImageExists

func (c *APIClient) ImageExists(
	ctx context.Context,
	digest string,
) (bool, error)

func (*APIClient) Logs

func (c *APIClient) Logs(ctx context.Context, cID string) (string, string, error)

func (*APIClient) PullImage

func (c *APIClient) PullImage(ctx context.Context, image string) error

func (*APIClient) Remove

func (c *APIClient) Remove(ctx context.Context, cID string) error

func (*APIClient) Start

func (c *APIClient) Start(ctx context.Context, cID string) error

func (*APIClient) Stop

func (c *APIClient) Stop(ctx context.Context, cID string) error

func (*APIClient) Wait

func (c *APIClient) Wait(ctx context.Context, cID string) (int, string, error)

type Client

type Client interface {
	Compatible(context.Context) (bool, error)
	ImageExists(context.Context, string) (bool, error)
	ContainerExists(context.Context, string) (bool, error)
	PullImage(context.Context, string) error
	Create(context.Context, Config) (string, error)
	Start(context.Context, string) error
	Wait(context.Context, string) (int, string, error)
	Logs(context.Context, string) (string, string, error)
	Stop(context.Context, string) error
	Remove(context.Context, string) error
}

type Config

type Config struct {
	Image      string
	Name       string
	User       string
	Env        []string
	Cmd        []string
	WorkingDir string
	Tmpfs      map[string]string
	Binds      []string
	AutoRemove bool
}

type CreateConfig

type CreateConfig struct {
	Image      string     `json:"Image"`
	User       string     `json:"User"`
	Env        []string   `json:"Env"`
	WorkingDir string     `json:"WorkingDir"`
	Cmd        []string   `json:"Cmd"`
	HostConfig HostConfig `json:"HostConfig"`
	TTY        bool       `json:"Tty"`
}

func NewCreateConfig

func NewCreateConfig(in Config) CreateConfig

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

type HostConfig

type HostConfig struct {
	Tmpfs      map[string]string `json:"Tmpfs"`
	Binds      []string          `json:"Binds"`
	AutoRemove bool              `json:"AutoRemove"`
}

type Memory

type Memory interface {
	AddID(string) error
	RemoveID(string) error
}

type Output

type Output struct {
	Status   int
	ErrorMsg string
	StdOut   string
	StdErr   string
}

type Runtime

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

func NewRuntime

func NewRuntime(mem Memory, log *slog.Logger) *Runtime

func NewRuntimeFromRaw

func NewRuntimeFromRaw(client Client, mem Memory, log *slog.Logger) *Runtime

func (*Runtime) CleanUp

func (r *Runtime) CleanUp(
	ctx context.Context,
	cID string,
) error

func (*Runtime) Compatible

func (r *Runtime) Compatible(ctx context.Context) (bool, error)

func (*Runtime) GetImage

func (r *Runtime) GetImage(
	ctx context.Context,
	image string,
) error

func (*Runtime) GetOutput

func (r *Runtime) GetOutput(
	ctx context.Context,
	cID string,
) (Output, error)

func (*Runtime) Launch

func (r *Runtime) Launch(
	ctx context.Context,
	cfg Config,
) (string, error)

func (*Runtime) Run

func (r *Runtime) Run(
	ctx context.Context,
	cfg Config,
) (Output, error)

type ServerMsg

type ServerMsg struct {
	Msg string `json:"message"`
}

Jump to

Keyboard shortcuts

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