Documentation
¶
Index ¶
- func CreateGitHubAuthConfig() (*registry.AuthConfig, string, error)
- func DisplayDockerProgress(reader io.Reader) error
- func IsRunningInContainer() bool
- func MergeMetadataEnv(ext *ExtensionConfig, meta *cache.ExtensionMeta)
- type AnsiFilter
- type CleanupResult
- type ContainerCleanupOptions
- type ContainerHost
- func (ch *ContainerHost) AttachToContainer(containerID string) (types.HijackedResponse, error)
- func (ch *ContainerHost) BuildEnvironmentVars(ext *ExtensionConfig) []string
- func (ch *ContainerHost) CleanupChildContainers() error
- func (ch *ContainerHost) CleanupContainers(opts ContainerCleanupOptions) (*CleanupResult, error)
- func (ch *ContainerHost) CleanupExtensionContainers(includeRunning, dryRun bool) (*CleanupResult, error)
- func (ch *ContainerHost) CleanupOldContainers(olderThan time.Duration, dryRun bool) (*CleanupResult, error)
- func (ch *ContainerHost) CleanupOrphanedContainers() error
- func (ch *ContainerHost) CleanupStoppedContainers(dryRun bool) (*CleanupResult, error)
- func (ch *ContainerHost) Close() error
- func (ch *ContainerHost) CreateContainer(containerConfig *container.Config, hostConfig *container.HostConfig) (string, error)
- func (ch *ContainerHost) CreateContainerConfig(ext *ExtensionConfig, mode ContainerMode, args []string, ...) *container.Config
- func (ch *ContainerHost) CreateHostConfig(ext *ExtensionConfig, volumeRequests []cache.VolumeRequest) *container.HostConfig
- func (ch *ContainerHost) EnsureImageExists(imageName string, pullPolicy string, loadLocal bool) error
- func (ch *ContainerHost) EnsureMultipleImages(imageNames []string, pullPolicy string, loadLocal bool) []ImagePullResult
- func (ch *ContainerHost) ExecuteMetadataCommand(ext *ExtensionConfig) (string, error)
- func (ch *ContainerHost) FindExtension(name string) (*ExtensionConfig, error)
- func (ch *ContainerHost) GetContainerSnapshot() (map[string]string, error)
- func (ch *ContainerHost) GetExtensionMetadata(ext *ExtensionConfig) (*cache.ExtensionMeta, error)
- func (ch *ContainerHost) GetImageDigest(imageName string) (string, error)
- func (ch *ContainerHost) GetRootDir() string
- func (ch *ContainerHost) InspectImage(image string) (*image.InspectResponse, error)
- func (ch *ContainerHost) ParallelEnsureImages(requests []ImagePullRequest, opts *ParallelImagePullOptions) []ImagePullResult
- func (ch *ContainerHost) StartContainer(containerID string) error
- func (ch *ContainerHost) StopContainer(containerID string) error
- func (ch *ContainerHost) StopContainerWithContext(ctx context.Context, containerID string) error
- func (ch *ContainerHost) ValidateExtensions() error
- func (ch *ContainerHost) WaitForContainer(containerID string) (<-chan container.WaitResponse, <-chan error)
- func (ch *ContainerHost) WarnAboutNewContainers(beforeSnapshot, afterSnapshot map[string]string, extensionImage string, ...)
- type ContainerMode
- type DockerClient
- type DockerError
- type DockerProgress
- type ExtensionConfig
- type ImagePullRequest
- type ImagePullResult
- type MockDockerClient
- func (m *MockDockerClient) Close() error
- func (m *MockDockerClient) ContainerAttach(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error)
- func (m *MockDockerClient) ContainerCreate(ctx context.Context, config *container.Config, ...) (container.CreateResponse, error)
- func (m *MockDockerClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
- func (m *MockDockerClient) ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error)
- func (m *MockDockerClient) ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
- func (m *MockDockerClient) ContainerResize(ctx context.Context, containerID string, options container.ResizeOptions) error
- func (m *MockDockerClient) ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
- func (m *MockDockerClient) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
- func (m *MockDockerClient) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
- func (m *MockDockerClient) ImageInspect(ctx context.Context, imageID string) (image.InspectResponse, error)
- func (m *MockDockerClient) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
- func (m *MockDockerClient) ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error)
- func (m *MockDockerClient) Ping(ctx context.Context) (types.Ping, error)
- func (m *MockDockerClient) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
- type ParallelImagePullOptions
- type RealDockerClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateGitHubAuthConfig ¶
func CreateGitHubAuthConfig() (*registry.AuthConfig, string, error)
CreateGitHubAuthConfig creates authentication configuration for GitHub Container Registry Returns both the registry.AuthConfig and base64-encoded auth string for Docker API calls
func DisplayDockerProgress ¶
DisplayDockerProgress reads Docker JSON progress and displays it to the user
func IsRunningInContainer ¶
func IsRunningInContainer() bool
IsRunningInContainer detects if we're running inside a Docker container
func MergeMetadataEnv ¶
func MergeMetadataEnv(ext *ExtensionConfig, meta *cache.ExtensionMeta)
MergeMetadataEnv merges environment variables from extension metadata into config Metadata env vars are added first, then config env vars override them
Types ¶
type AnsiFilter ¶
type AnsiFilter struct {
// contains filtered or unexported fields
}
AnsiFilter wraps an io.Writer and filters out problematic ANSI sequences while preserving useful ones like colors and basic formatting.
Preserved sequences: - SGR (Select Graphic Rendition) for colors and text formatting: ESC[...m - Basic cursor movement: ESC[A (up), ESC[B (down), ESC[C (forward), ESC[D (backward) - Line clearing: ESC[K, ESC[2K - Screen clearing: ESC[2J
Filtered sequences: - Cursor position reports (CPR): ESC[row;colR - Device status reports: ESC[6n, ESC[5n - Cursor position queries: ESC[H, ESC[f - Terminal mode changes - Mouse tracking - Alternate screen buffer switches - Terminal title changes - Bracketed paste mode - Cursor visibility changes
func NewAnsiFilter ¶
func NewAnsiFilter(w io.Writer) *AnsiFilter
NewAnsiFilter creates a new ANSI filter that wraps the given writer
type CleanupResult ¶
CleanupResult represents the result of a cleanup operation
type ContainerCleanupOptions ¶
type ContainerCleanupOptions struct {
OnlyExtensions bool // Only clean extension containers
IncludeRunning bool // Also remove running containers (default: false)
OlderThan time.Duration // Only remove containers older than this duration
DryRun bool // Show what would be removed without removing
}
ContainerCleanupOptions configures container cleanup behavior
type ContainerHost ¶
type ContainerHost struct {
// contains filtered or unexported fields
}
ContainerHost manages Docker container operations for extensions
func NewContainerHost ¶
func NewContainerHost() (*ContainerHost, error)
NewContainerHost creates a new ContainerHost instance
func (*ContainerHost) AttachToContainer ¶
func (ch *ContainerHost) AttachToContainer(containerID string) (types.HijackedResponse, error)
AttachToContainer attaches to a container for I/O operations
func (*ContainerHost) BuildEnvironmentVars ¶
func (ch *ContainerHost) BuildEnvironmentVars(ext *ExtensionConfig) []string
BuildEnvironmentVars creates the environment variable list for a container
func (*ContainerHost) CleanupChildContainers ¶
func (ch *ContainerHost) CleanupChildContainers() error
CleanupChildContainers stops all containers that were started from within this container This is useful for Docker-in-Docker scenarios where the parent container starts child containers
func (*ContainerHost) CleanupContainers ¶
func (ch *ContainerHost) CleanupContainers(opts ContainerCleanupOptions) (*CleanupResult, error)
CleanupContainers removes containers based on the provided options
func (*ContainerHost) CleanupExtensionContainers ¶
func (ch *ContainerHost) CleanupExtensionContainers(includeRunning, dryRun bool) (*CleanupResult, error)
CleanupExtensionContainers is a convenience wrapper for cleaning up extension containers
func (*ContainerHost) CleanupOldContainers ¶
func (ch *ContainerHost) CleanupOldContainers(olderThan time.Duration, dryRun bool) (*CleanupResult, error)
CleanupOldContainers removes containers older than the specified duration
func (*ContainerHost) CleanupOrphanedContainers ¶
func (ch *ContainerHost) CleanupOrphanedContainers() error
CleanupOrphanedContainers removes containers that match r2r-cli patterns but are no longer needed
func (*ContainerHost) CleanupStoppedContainers ¶
func (ch *ContainerHost) CleanupStoppedContainers(dryRun bool) (*CleanupResult, error)
CleanupStoppedContainers is a convenience wrapper for cleaning up all stopped containers
func (*ContainerHost) Close ¶
func (ch *ContainerHost) Close() error
func (*ContainerHost) CreateContainer ¶
func (ch *ContainerHost) CreateContainer(containerConfig *container.Config, hostConfig *container.HostConfig) (string, error)
CreateContainer creates a new Docker container with the specified configuration
func (*ContainerHost) CreateContainerConfig ¶
func (ch *ContainerHost) CreateContainerConfig(ext *ExtensionConfig, mode ContainerMode, args []string, imageInspect *image.InspectResponse) *container.Config
CreateContainerConfig creates a container configuration based on mode and extension
func (*ContainerHost) CreateHostConfig ¶
func (ch *ContainerHost) CreateHostConfig(ext *ExtensionConfig, volumeRequests []cache.VolumeRequest) *container.HostConfig
CreateHostConfig creates the host configuration with volume mounts volumeRequests are optional cache volumes requested by the extension via metadata
func (*ContainerHost) EnsureImageExists ¶
func (ch *ContainerHost) EnsureImageExists(imageName string, pullPolicy string, loadLocal bool) error
EnsureImageExists checks if an image exists locally and pulls it based on the pull policy
func (*ContainerHost) EnsureMultipleImages ¶
func (ch *ContainerHost) EnsureMultipleImages(imageNames []string, pullPolicy string, loadLocal bool) []ImagePullResult
EnsureMultipleImages is a convenience wrapper for pulling multiple images with the same policy
func (*ContainerHost) ExecuteMetadataCommand ¶
func (ch *ContainerHost) ExecuteMetadataCommand(ext *ExtensionConfig) (string, error)
ExecuteMetadataCommand executes the "extension-meta" command in an extension container and returns the raw YAML output string or an error. Note: Callers must ensure the image exists before calling this function.
func (*ContainerHost) FindExtension ¶
func (ch *ContainerHost) FindExtension(name string) (*ExtensionConfig, error)
FindExtension locates an extension by name in the configuration
func (*ContainerHost) GetContainerSnapshot ¶
func (ch *ContainerHost) GetContainerSnapshot() (map[string]string, error)
Close closes the Docker client connection GetContainerSnapshot returns a snapshot of currently running containers
func (*ContainerHost) GetExtensionMetadata ¶
func (ch *ContainerHost) GetExtensionMetadata(ext *ExtensionConfig) (*cache.ExtensionMeta, error)
GetExtensionMetadata fetches and caches extension metadata Returns cached metadata if valid, otherwise fetches fresh metadata
func (*ContainerHost) GetImageDigest ¶
func (ch *ContainerHost) GetImageDigest(imageName string) (string, error)
GetImageDigest returns the digest of a Docker image for cache invalidation Returns the image ID if no repo digests are available (local images)
func (*ContainerHost) GetRootDir ¶
func (ch *ContainerHost) GetRootDir() string
GetRootDir returns the root directory path
func (*ContainerHost) InspectImage ¶
func (ch *ContainerHost) InspectImage(image string) (*image.InspectResponse, error)
InspectImage inspects a Docker image and returns the inspection result
func (*ContainerHost) ParallelEnsureImages ¶
func (ch *ContainerHost) ParallelEnsureImages(requests []ImagePullRequest, opts *ParallelImagePullOptions) []ImagePullResult
ParallelEnsureImages pulls multiple images in parallel This is useful when starting multiple extensions that may need image pulls
func (*ContainerHost) StartContainer ¶
func (ch *ContainerHost) StartContainer(containerID string) error
StartContainer starts a Docker container by ID
func (*ContainerHost) StopContainer ¶
func (ch *ContainerHost) StopContainer(containerID string) error
StopContainer stops a running container
func (*ContainerHost) StopContainerWithContext ¶
func (ch *ContainerHost) StopContainerWithContext(ctx context.Context, containerID string) error
StopContainerWithContext stops a running container with a specific context for timeout control
func (*ContainerHost) ValidateExtensions ¶
func (ch *ContainerHost) ValidateExtensions() error
ValidateExtensions checks if extensions are configured
func (*ContainerHost) WaitForContainer ¶
func (ch *ContainerHost) WaitForContainer(containerID string) (<-chan container.WaitResponse, <-chan error)
WaitForContainer waits for a container to finish execution
func (*ContainerHost) WarnAboutNewContainers ¶
func (ch *ContainerHost) WarnAboutNewContainers(beforeSnapshot, afterSnapshot map[string]string, extensionImage string, autoRemove bool, expectedHostImages []string)
WarnAboutNewContainers compares before/after snapshots and warns about new containers If autoRemove is true, it will stop and remove the containers instead of just warning expectedHostImages is a list of images that are expected to be created by the extension (e.g., serve commands)
type ContainerMode ¶
type ContainerMode int
ContainerMode defines how the container should be configured
const ( ModeRun ContainerMode = iota ModeInteractive )
type DockerClient ¶
type DockerClient interface {
// Ping pings the Docker daemon to verify connectivity
Ping(ctx context.Context) (types.Ping, error)
// ImageInspect inspects a Docker image and returns detailed information
ImageInspect(ctx context.Context, imageID string) (image.InspectResponse, error)
// ImageList lists Docker images
ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
// ImagePull pulls a Docker image from a registry
ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error)
// RegistryLogin authenticates with a Docker registry
RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
// ContainerCreate creates a new container
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
// ContainerStart starts a container
ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
// ContainerInspect inspects a container and returns detailed information
ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
// ContainerResize resizes the TTY of a container
ContainerResize(ctx context.Context, containerID string, options container.ResizeOptions) error
// ContainerAttach attaches to a container for I/O operations
ContainerAttach(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error)
// ContainerWait waits for a container to finish execution
ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
// ContainerStop stops a running container
ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
// ContainerRemove removes a container
ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
// ContainerList lists containers
ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error)
// Close closes the Docker client connection
Close() error
}
DockerClient defines the interface for Docker operations used by the CLI module. This interface allows for mocking Docker operations in unit tests.
func NewRealDockerClient ¶
func NewRealDockerClient(opts ...client.Opt) (DockerClient, error)
NewRealDockerClient creates a new RealDockerClient instance
type DockerError ¶
type DockerError struct {
Error string `json:"error"`
}
DockerError represents a Docker error response
type DockerProgress ¶
type DockerProgress struct {
Status string `json:"status"`
Progress string `json:"progress"`
ProgressDetail struct {
Current int64 `json:"current"`
Total int64 `json:"total"`
} `json:"progressDetail"`
ID string `json:"id"`
}
DockerProgress represents a Docker progress update
type ExtensionConfig ¶
type ExtensionConfig struct {
Name string
Image string
ImagePullPolicy string
LoadLocal bool
AutoRemoveChildren bool
Env []conf.EnvVar
}
ExtensionConfig holds the configuration for an extension
type ImagePullRequest ¶
type ImagePullRequest struct {
ImageName string
PullPolicy string
LoadLocal bool
Index int // Original index for result mapping
}
ImagePullRequest represents a single image pull operation
type ImagePullResult ¶
ImagePullResult represents the result of an image pull operation
type MockDockerClient ¶
MockDockerClient is a mock implementation of DockerClient for testing
func (*MockDockerClient) Close ¶
func (m *MockDockerClient) Close() error
func (*MockDockerClient) ContainerAttach ¶
func (m *MockDockerClient) ContainerAttach(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error)
func (*MockDockerClient) ContainerCreate ¶
func (m *MockDockerClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
func (*MockDockerClient) ContainerInspect ¶
func (m *MockDockerClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
func (*MockDockerClient) ContainerList ¶
func (m *MockDockerClient) ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error)
func (*MockDockerClient) ContainerRemove ¶
func (m *MockDockerClient) ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
func (*MockDockerClient) ContainerResize ¶
func (m *MockDockerClient) ContainerResize(ctx context.Context, containerID string, options container.ResizeOptions) error
func (*MockDockerClient) ContainerStart ¶
func (m *MockDockerClient) ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
func (*MockDockerClient) ContainerStop ¶
func (m *MockDockerClient) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
func (*MockDockerClient) ContainerWait ¶
func (m *MockDockerClient) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
func (*MockDockerClient) ImageInspect ¶
func (m *MockDockerClient) ImageInspect(ctx context.Context, imageID string) (image.InspectResponse, error)
func (*MockDockerClient) ImageList ¶
func (m *MockDockerClient) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
func (*MockDockerClient) ImagePull ¶
func (m *MockDockerClient) ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error)
func (*MockDockerClient) RegistryLogin ¶
func (m *MockDockerClient) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
type ParallelImagePullOptions ¶
type ParallelImagePullOptions struct {
MaxConcurrency int // Maximum number of concurrent pulls (default: 3)
}
ParallelImagePullOptions configures parallel image pull behavior
type RealDockerClient ¶
RealDockerClient wraps the official Docker client to implement DockerClient interface
func (*RealDockerClient) ImageInspect ¶
func (r *RealDockerClient) ImageInspect(ctx context.Context, imageID string) (image.InspectResponse, error)
ImageInspect wraps the client ImageInspect to match our interface (without variadic options)