contain

package
v0.0.230 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentImageDockerfilePath

func AgentImageDockerfilePath() (string, error)

AgentImageDockerfilePath returns the stable managed legacy Arch Dockerfile path for the built-in agent runtime image.

func AgentImageHash

func AgentImageHash() (string, error)

AgentImageHash returns a deterministic short hex fingerprint of the embedded agent image build context. The hash changes whenever any embedded file under images/agent is added, removed, renamed, or modified. It is suffixed onto the agent image tag so changes to embedded content force a fresh image instead of silently reusing a cached tag.

func BuiltinImageNames

func BuiltinImageNames() []string

BuiltinImageNames returns supported managed image asset names.

func BuiltinTemplateNames

func BuiltinTemplateNames() []string

BuiltinTemplateNames returns the built-in contain template names.

func ComposeBaseArgs

func ComposeBaseArgs(name string) ([]string, string, error)

func ComposePath

func ComposePath(name string) (string, error)

ComposePath returns the canonical compose.yaml path for a named contain workspace.

func ContainerDir

func ContainerDir(name string) (string, error)

ContainerDir returns the configuration directory for a named contain workspace.

func ContainersRoot

func ContainersRoot() (string, error)

ContainersRoot returns the global directory containing named contain workspaces.

func CreateWorkspace

func CreateWorkspace(name string, opts CreateOptions) (string, error)

CreateWorkspace renders the selected template into the named global contain workspace directory. Existing targets are never overwritten.

func DockerPS

func DockerPS(ctx context.Context, runner Runner, stderr io.Writer) ([]byte, error)

func Exec

func Exec(ctx context.Context, runner Runner, name string, cmdArgs []string, stdin io.Reader, stdout, stderr io.Writer) error

func ImageDir

func ImageDir(name string) (string, error)

ImageDir returns the managed directory for an image asset.

func ImagesRoot

func ImagesRoot() (string, error)

ImagesRoot returns the directory containing managed contain image assets.

func IsBuiltinTemplate

func IsBuiltinTemplate(name string) bool

IsBuiltinTemplate reports whether name is a built-in contain template.

func PrintList

func PrintList(entries []ListEntry, w io.Writer) error

func ProjectName

func ProjectName(name string) string

ProjectName returns the deterministic Docker Compose project name for a contain workspace.

func Rebuild

func Rebuild(ctx context.Context, runner Runner, name string, stdout, stderr io.Writer) error

Rebuild rebuilds workspace images without cache, pulls newer base images where Compose can, and recreates containers while preserving volumes/networks.

func Remove

func Remove(ctx context.Context, runner Runner, name string, stdout, stderr io.Writer) error

Remove permanently deletes a contain workspace: Compose resources are brought down with volumes removed, then the workspace definition directory is deleted.

func RenderTemplateContent

func RenderTemplateContent(data []byte, values PlaceholderValues) ([]byte, error)

RenderTemplateContent applies simple placeholder substitution to data.

func ResolveTemplateValues

func ResolveTemplateValues(desc *TemplateDescriptor, provided map[string]string, noInput bool, stdin io.Reader, stdout io.Writer) (map[string]string, error)

func SafeName

func SafeName(name string) string

SafeName returns the deterministic name fragment used for Docker Compose project names and Docker resource names. It is tolerant so callers can use it in error paths, but valid workspace names should be checked with ValidateName.

func Shell

func Shell(ctx context.Context, runner Runner, name string, stdin io.Reader, stdout, stderr io.Writer) error

func ShellWithOptions added in v0.0.193

func ShellWithOptions(ctx context.Context, runner Runner, name string, opts ShellOptions, stdin io.Reader, stdout, stderr io.Writer) error

func Start

func Start(ctx context.Context, runner Runner, name string, stdout, stderr io.Writer) error

func Stop

func Stop(ctx context.Context, runner Runner, name string, stdout, stderr io.Writer) error

func ValidateName

func ValidateName(name string) error

ValidateName validates a contain workspace name. Names are intentionally limited to simple path-safe characters because they are used as directory names below the global containers root.

Types

type ComposeInfo

type ComposeInfo struct {
	Path          string
	Services      map[string]ServiceInfo
	Hints         Hints
	Invalid       bool
	InvalidReason string
}

func ReadComposeInfo

func ReadComposeInfo(path string) (ComposeInfo, error)

ReadComposeInfo lightly parses the Compose file for term-llm hints, service names, and labels. It intentionally does not fully validate Compose.

func (ComposeInfo) DefaultService

func (i ComposeInfo) DefaultService() string

func (ComposeInfo) DefaultUser added in v0.0.193

func (i ComposeInfo) DefaultUser(service string) string

func (ComposeInfo) Shell

func (i ComposeInfo) Shell() string

type CreateOptions

type CreateOptions struct {
	Template string
	CWD      string
	Values   map[string]string
	NoInput  bool
	Stdin    io.Reader
	Stdout   io.Writer
}

type ExecRecipe added in v0.0.195

type ExecRecipe struct {
	Name        string
	Description string
	Command     []string
}

type Hints

type Hints struct {
	Purpose        string
	Workspace      string
	DefaultService string
	Shell          string
	PreferredCLI   string
	Agent          string
	ExecRecipes    map[string]ExecRecipe
}

type ImageSyncResult

type ImageSyncResult struct {
	Name    string
	Dir     string
	Files   []string
	Updated bool
}

func SyncImage

func SyncImage(name string, force bool) (ImageSyncResult, error)

SyncImage writes a managed embedded image asset into the user's config dir. Existing managed files are updated. Non-managed existing files are not overwritten unless force is true.

type ListEntry

type ListEntry struct {
	Name      string
	Status    string
	Service   string
	ConfigDir string
}

func Definitions

func Definitions() ([]ListEntry, error)

Definitions scans global contain workspace definitions without consulting Docker.

func List

func List(ctx context.Context, runner Runner, stderr io.Writer) ([]ListEntry, error)

List scans contain definitions and reconciles them with labelled Docker containers.

type OSRunner

type OSRunner struct{}

func (OSRunner) Output

func (OSRunner) Output(ctx context.Context, name string, args []string, opts RunOptions) ([]byte, error)

func (OSRunner) Run

func (OSRunner) Run(ctx context.Context, name string, args []string, opts RunOptions) error

type PlaceholderValues

type PlaceholderValues map[string]string

func NewPlaceholderValues

func NewPlaceholderValues(name, cwd, configDir, containersDir, composePath string) PlaceholderValues

NewPlaceholderValues builds the supported replacement values for contain templates.

type RunOptions

type RunOptions struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	Dir    string
}

type Runner

type Runner interface {
	Run(ctx context.Context, name string, args []string, opts RunOptions) error
	Output(ctx context.Context, name string, args []string, opts RunOptions) ([]byte, error)
}

type ServiceInfo

type ServiceInfo struct {
	Name         string
	Labels       map[string]string
	BuildContext string
}

type ShellOptions added in v0.0.193

type ShellOptions struct {
	User string
}

type Template

type Template struct {
	Name       string
	Source     string
	Builtin    bool
	Descriptor *TemplateDescriptor
	Files      []TemplateFile
}

func LoadTemplate

func LoadTemplate(ref string) (*Template, error)

LoadTemplate resolves a built-in, single-file, or directory template.

type TemplateCondition

type TemplateCondition struct {
	Equals map[string]string `yaml:"equals"`
}

type TemplateDescriptor

type TemplateDescriptor struct {
	Version     int              `yaml:"version"`
	Name        string           `yaml:"name"`
	Description string           `yaml:"description"`
	Prompts     []TemplatePrompt `yaml:"prompts"`
}

type TemplateFile

type TemplateFile struct {
	Path string
	Data []byte
	Mode fs.FileMode
}

type TemplatePrompt

type TemplatePrompt struct {
	ID       string             `yaml:"id"`
	Label    string             `yaml:"label"`
	Type     string             `yaml:"type"`
	Default  any                `yaml:"default"`
	Options  []string           `yaml:"options"`
	Required bool               `yaml:"required"`
	When     *TemplateCondition `yaml:"when"`
}

Jump to

Keyboard shortcuts

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