container

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package container provides utilities for managing containers, including creating, starting, stopping, and monitoring containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRuntimeAvailable added in v0.3.0

func CheckRuntimeAvailable() error

CheckRuntimeAvailable checks if any container runtime is available and returns a user-friendly error message if none are found

func GetOrGenerateContainerName

func GetOrGenerateContainerName(containerName, image string) (string, string)

GetOrGenerateContainerName generates a container name if not provided. It returns both the container name and the base name. If containerName is not empty, it will be used as both the container name and base name. If containerName is empty, a name will be generated based on the image.

func NewMonitor

func NewMonitor(rt runtime.Runtime, containerName string) runtime.Monitor

NewMonitor creates a new container monitor

Types

type Factory

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

Factory creates container runtimes with pluggable runtime support

func NewFactory

func NewFactory() *Factory

NewFactory creates a new container factory with default runtimes registered

func (*Factory) Clear added in v0.2.11

func (f *Factory) Clear()

Clear removes all registered runtimes This is useful for testing or when you want to start with a clean slate

func (*Factory) Create

func (f *Factory) Create(ctx context.Context) (runtime.Runtime, error)

Create creates a container runtime It first checks the TOOLHIVE_RUNTIME environment variable for a specific runtime, otherwise falls back to auto-detection

func (*Factory) CreateWithRuntimeName added in v0.2.11

func (f *Factory) CreateWithRuntimeName(ctx context.Context, runtimeName string) (runtime.Runtime, error)

CreateWithRuntimeName creates a container runtime with a specific runtime name If runtimeName is empty, it falls back to auto-detection

func (*Factory) GetRuntime added in v0.2.11

func (f *Factory) GetRuntime(name string) (*RuntimeInfo, bool)

GetRuntime retrieves a runtime info by name

func (*Factory) ListAvailableRuntimes added in v0.2.11

func (f *Factory) ListAvailableRuntimes() map[string]*RuntimeInfo

ListAvailableRuntimes returns all runtimes that are currently available

func (*Factory) ListRuntimes added in v0.2.11

func (f *Factory) ListRuntimes() map[string]*RuntimeInfo

ListRuntimes returns all registered runtimes

func (*Factory) Register added in v0.2.11

func (f *Factory) Register(info *RuntimeInfo) error

Register registers a new runtime with the factory

func (*Factory) Unregister added in v0.2.11

func (f *Factory) Unregister(name string)

Unregister removes a runtime from the factory

type RuntimeInfo added in v0.2.11

type RuntimeInfo struct {
	// Name is the runtime name (e.g., "docker", "kubernetes")
	Name string
	// Initializer is the function to create the runtime instance
	Initializer RuntimeInitializer
	// AutoDetector is an optional function to detect if this runtime is available
	// If nil, the runtime is always considered available
	AutoDetector func() bool
}

RuntimeInfo contains metadata about a runtime

type RuntimeInitializer added in v0.2.11

type RuntimeInitializer func(ctx context.Context) (runtime.Runtime, error)

RuntimeInitializer is a function that creates a new runtime instance

Directories

Path Synopsis
Package docker provides Docker-specific implementation of container runtime, including creating, starting, stopping, and monitoring containers.
Package docker provides Docker-specific implementation of container runtime, including creating, starting, stopping, and monitoring containers.
sdk
Package sdk provides a factory method for creating a Docker client.
Package sdk provides a factory method for creating a Docker client.
Package images handles container image management operations.
Package images handles container image management operations.
Package kubernetes provides a client for the Kubernetes runtime including creating, starting, stopping, and retrieving container information.
Package kubernetes provides a client for the Kubernetes runtime including creating, starting, stopping, and retrieving container information.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package runtime provides interfaces and types for container runtimes, including creating, starting, stopping, and monitoring containers.
Package runtime provides interfaces and types for container runtimes, including creating, starting, stopping, and monitoring containers.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package templates provides utilities for generating Dockerfile templates based on different transport types (uvx, npx).
Package templates provides utilities for generating Dockerfile templates based on different transport types (uvx, npx).
Package verifier provides a client for verifying artifacts using sigstore
Package verifier provides a client for verifying artifacts using sigstore

Jump to

Keyboard shortcuts

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