docker

package
v0.0.0-...-d39526f Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClaudeCredentialsVolume is the name of the Docker volume for Claude credentials
	ClaudeCredentialsVolume = "worklet-claude-credentials"
)
View Source
const (
	// SSHCredentialsVolume is the name of the Docker volume for SSH credentials
	SSHCredentialsVolume = "worklet-ssh-credentials"
)
View Source
const WorkletNetworkName = "worklet-network"

Variables

This section is empty.

Functions

func AttachToSession

func AttachToSession(ctx context.Context, sessionID string) error

AttachToSession attaches to a running session container

func CheckClaudeCredentials

func CheckClaudeCredentials() (bool, error)

CheckClaudeCredentials checks if Claude credentials are configured

func CheckSSHCredentials

func CheckSSHCredentials() (bool, error)

CheckSSHCredentials checks if SSH credentials are configured

func CleanupAllOrphaned

func CleanupAllOrphaned(ctx context.Context, opts CleanupOptions) error

CleanupAllOrphaned removes all orphaned Docker resources

func CleanupOrphanedImages

func CleanupOrphanedImages(ctx context.Context) (int, error)

CleanupOrphanedImages removes temporary worklet images

func CleanupOrphanedNetworks

func CleanupOrphanedNetworks() (int, error)

CleanupOrphanedNetworks removes all worklet networks that have no connected containers

func CleanupOrphanedVolumes

func CleanupOrphanedVolumes(ctx context.Context, opts CleanupOptions) (int, error)

CleanupOrphanedVolumes removes worklet volumes not associated with running containers

func CleanupSession

func CleanupSession(ctx context.Context, sessionID string, opts CleanupOptions) error

CleanupSession removes all Docker resources associated with a session

func ClearClaudeCredentials

func ClearClaudeCredentials() error

ClearClaudeCredentials removes Claude credentials

func ClearSSHCredentials

func ClearSSHCredentials() error

ClearSSHCredentials removes SSH credentials

func CreateNetwork

func CreateNetwork(networkName string) error

CreateNetwork creates a Docker network

func CreateVolume

func CreateVolume(volumeName string) error

CreateVolume creates a Docker volume if it doesn't exist

func EnsureDevContainerConfig

func EnsureDevContainerConfig(containerID string, projectName string) error

EnsureDevContainerConfig ensures container has devcontainer.json

func EnsureNetworkExists

func EnsureNetworkExists() error

EnsureNetworkExists creates the worklet Docker network if it doesn't exist Deprecated: Use EnsureSessionNetworkExists for session-specific networks

func EnsureSessionNetworkExists

func EnsureSessionNetworkExists(sessionID string) error

EnsureSessionNetworkExists creates a session-specific Docker network if it doesn't exist

func ExecShell

func ExecShell(ctx context.Context, sessionID string) (*exec.Cmd, error)

ExecShell creates an interactive shell session in a container

func GenerateDevContainerConfig

func GenerateDevContainerConfig(projectName string) (string, error)

GenerateDevContainerConfig creates devcontainer.json content

func GetComposePath

func GetComposePath(workDir string, composePath string) string

GetComposePath determines the path to the docker-compose file

func GetCredentialInitScript

func GetCredentialInitScript(mountClaude bool) string

GetCredentialInitScript returns initialization commands for setting up credentials

func GetCredentialVolumeMounts

func GetCredentialVolumeMounts(mountClaude bool) []string

GetCredentialVolumeMounts returns volume mount arguments for credential volumes

func GetProjectNameFromContainer

func GetProjectNameFromContainer(containerID string) string

GetProjectNameFromContainer retrieves the project name from container labels

func GetSSHInitScript

func GetSSHInitScript(mountSSH bool) string

GetSSHInitScript returns initialization commands for setting up SSH

func GetSSHVolumeMounts

func GetSSHVolumeMounts(mountSSH bool) []string

GetSSHVolumeMounts returns volume mount arguments for SSH credentials

func GetSessionDNSName

func GetSessionDNSName(session SessionInfo, service ServiceInfo) string

GetSessionDNSName generates the DNS name for a session service

func GetSessionNetworkName

func GetSessionNetworkName(sessionID string) string

GetSessionNetworkName returns the network name for a session

func GetUserVSCodeExtensions

func GetUserVSCodeExtensions() ([]string, error)

GetUserVSCodeExtensions returns list of user's installed VSCode extensions

func ListNetworkContainers

func ListNetworkContainers(networkName string) ([]string, error)

ListNetworkContainers lists containers connected to a network

func NetworkExists

func NetworkExists(networkName string) (bool, error)

NetworkExists checks if a Docker network exists

func RemoveNetwork

func RemoveNetwork(networkName string) error

RemoveNetwork removes a Docker network

func RemoveSession

func RemoveSession(ctx context.Context, sessionID string) error

RemoveSession removes a worklet session and all associated resources

func RemoveSessionForce

func RemoveSessionForce(ctx context.Context, sessionID string) error

RemoveSessionForce removes a worklet session and ALL associated resources including pnpm volumes

func RemoveSessionNetwork

func RemoveSessionNetwork(sessionID string) error

RemoveSessionNetwork removes a session-specific Docker network

func RemoveSessionNetworkSafe

func RemoveSessionNetworkSafe(sessionID string) error

RemoveSessionNetworkSafe removes a session-specific Docker network only if no containers are connected

func RemoveVolume

func RemoveVolume(volumeName string) error

RemoveVolume removes a Docker volume

func RunContainer

func RunContainer(opts RunOptions) (string, error)

RunContainer runs a container in detached mode and returns the container ID

func SetupClaudeCredentials

func SetupClaudeCredentials() error

SetupClaudeCredentials runs an interactive container to set up Claude credentials

func SetupSSHCredentials

func SetupSSHCredentials() error

SetupSSHCredentials runs an interactive container to set up SSH credentials

func StartComposeServices

func StartComposeServices(workDir, composePath, sessionID, projectName string, isolation string) error

StartComposeServices starts docker-compose services for a worklet session

func StopComposeServices

func StopComposeServices(workDir, composePath, sessionID, projectName string, isolation string) error

StopComposeServices stops docker-compose services for a worklet session

func StopSession

func StopSession(ctx context.Context, sessionID string) error

StopSession stops a worklet session container

func TailLogs

func TailLogs(ctx context.Context, containerID string, output chan<- string) error

func TestSSHGitHub

func TestSSHGitHub() (bool, string, error)

TestSSHGitHub tests if SSH credentials can connect to GitHub

func VolumeExists

func VolumeExists(volumeName string) (bool, error)

VolumeExists checks if a Docker volume exists

Types

type CleanupOptions

type CleanupOptions struct {
	Force bool // Force removal of shared resources like pnpm volumes
}

CleanupOptions configures cleanup behavior

type ComposeFile

type ComposeFile struct {
	Version  string                          `yaml:"version"`
	Services map[string]ComposeServiceConfig `yaml:"services"`
	Networks map[string]interface{}          `yaml:"networks,omitempty"`
}

ComposeFile represents the structure of a docker-compose.yml file

type ComposeService

type ComposeService struct {
	Name      string
	Image     string
	Ports     []string
	Networks  []string
	Container string // Container name when running
}

ComposeService represents a service from docker-compose.yml

func ParseComposeServices

func ParseComposeServices(composePath string) ([]ComposeService, error)

ParseComposeServices parses a docker-compose.yml file and extracts service information

type ComposeServiceConfig

type ComposeServiceConfig struct {
	Image       string                 `yaml:"image"`
	Ports       []string               `yaml:"ports"`
	Environment interface{}            `yaml:"environment,omitempty"`
	Volumes     []string               `yaml:"volumes,omitempty"`
	Networks    interface{}            `yaml:"networks,omitempty"`
	Labels      map[string]string      `yaml:"labels,omitempty"`
	Other       map[string]interface{} `yaml:",inline"`
}

ComposeServiceConfig represents a service configuration in docker-compose.yml

type DevContainerConfig

type DevContainerConfig struct {
	Name            string             `json:"name"`
	WorkspaceFolder string             `json:"workspaceFolder"`
	RemoteUser      string             `json:"remoteUser,omitempty"`
	Customizations  DevContainerCustom `json:"customizations"`
}

DevContainerConfig represents the devcontainer.json structure

type DevContainerCustom

type DevContainerCustom struct {
	VSCode DevContainerVSCode `json:"vscode"`
}

DevContainerCustom represents VSCode customizations

type DevContainerVSCode

type DevContainerVSCode struct {
	Extensions []string               `json:"extensions"`
	Settings   map[string]interface{} `json:"settings"`
}

DevContainerVSCode represents VSCode-specific settings

type NginxManager

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

NginxManager handles nginx proxy container operations

func NewNginxManager

func NewNginxManager(configPath string) (*NginxManager, error)

NewNginxManager creates a new nginx manager

func (*NginxManager) ConnectToNetwork

func (nm *NginxManager) ConnectToNetwork(ctx context.Context, networkName string) error

ConnectToNetwork connects the nginx container to a specific network

func (*NginxManager) EnsureConnectedToAllNetworks

func (nm *NginxManager) EnsureConnectedToAllNetworks(ctx context.Context) error

EnsureConnectedToAllNetworks ensures nginx is connected to all worklet session networks

func (*NginxManager) GetConfigPath

func (nm *NginxManager) GetConfigPath() string

GetConfigPath returns the nginx config file path

func (*NginxManager) IsHealthy

func (nm *NginxManager) IsHealthy(ctx context.Context) (bool, error)

IsHealthy checks if the nginx container is running and healthy

func (*NginxManager) Reload

func (nm *NginxManager) Reload(ctx context.Context) error

Reload reloads the nginx configuration

func (*NginxManager) Remove

func (nm *NginxManager) Remove(ctx context.Context) error

Remove removes the nginx proxy container

func (*NginxManager) Restart

func (nm *NginxManager) Restart(ctx context.Context) error

Restart restarts the nginx container with current configuration

func (*NginxManager) Start

func (nm *NginxManager) Start(ctx context.Context) error

Start starts the nginx proxy container

func (*NginxManager) Stop

func (nm *NginxManager) Stop(ctx context.Context) error

Stop stops the nginx proxy container

func (*NginxManager) UpdateConfig

func (nm *NginxManager) UpdateConfig(ctx context.Context, config string) error

UpdateConfig writes a new nginx configuration and reloads

type RunOptions

type RunOptions struct {
	WorkDir     string
	Config      *config.WorkletConfig
	SessionID   string
	MountMode   bool
	ComposePath string // Resolved compose path
	CmdArgs     []string
}

RunOptions contains all options for running a container

type ServiceInfo

type ServiceInfo struct {
	Name      string
	Port      int
	Subdomain string
}

ServiceInfo represents service information for daemon registration

func GetComposeServicesForDaemon

func GetComposeServicesForDaemon(composePath, sessionID, projectName string) ([]ServiceInfo, error)

GetComposeServicesForDaemon extracts service information for daemon registration

type SessionInfo

type SessionInfo struct {
	SessionID     string            `json:"session_id"`
	ProjectName   string            `json:"project_name"`
	ContainerID   string            `json:"container_id"`
	ContainerName string            `json:"container_name"`
	WorkDir       string            `json:"workdir"`
	Status        string            `json:"status"`
	Services      []ServiceInfo     `json:"services"`
	Labels        map[string]string `json:"labels"`
	CreatedAt     time.Time         `json:"created_at"`
}

SessionInfo represents information about a worklet session container

func GetSessionInfo

func GetSessionInfo(ctx context.Context, sessionID string) (*SessionInfo, error)

GetSessionInfo returns information about a specific session

func ListAllSessions

func ListAllSessions(ctx context.Context) ([]SessionInfo, error)

ListAllSessions returns all worklet sessions (including stopped) discovered via Docker API

func ListSessions

func ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions returns all running worklet sessions discovered via Docker API

func ListSessionsByProject

func ListSessionsByProject(ctx context.Context, projectName string) ([]SessionInfo, error)

ListSessionsByProject returns all sessions for a specific project

Jump to

Keyboard shortcuts

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