Documentation
¶
Index ¶
- Constants
- func LoadProject(ctx context.Context, paths []string, envFiles []string) (*types.Project, error)
- func ProjectName(workspaceID string) string
- type Helper
- func (h *Helper) Build(ctx context.Context, projectName string, files []string, services []string, ...) error
- func (h *Helper) BuiltImageName(projectName, serviceName string) string
- func (h *Helper) Down(ctx context.Context, projectName string, files []string, ...) error
- func (h *Helper) ListContainers(ctx context.Context, projectName string, files []string, extraEnv []string) ([]string, error)
- func (h *Helper) ListServiceStatuses(ctx context.Context, projectName string, files []string, extraEnv []string) ([]ServiceStatus, error)
- func (h *Helper) Logs(ctx context.Context, projectName string, files []string, follow bool, ...) error
- func (h *Helper) Restart(ctx context.Context, projectName string, files []string, ...) error
- func (h *Helper) Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer, ...) error
- func (h *Helper) RuntimeCommand() string
- func (h *Helper) Stop(ctx context.Context, projectName string, files []string, ...) error
- func (h *Helper) Up(ctx context.Context, projectName string, files []string, services []string, ...) error
- func (h *Helper) Version() string
- type PortBinding
- type ServiceInfo
- type ServiceStatus
Constants ¶
const ( // ProjectLabel is the label used by Docker Compose to identify project containers. ProjectLabel = "com.docker.compose.project" // ServiceLabel is the label used by Docker Compose to identify service containers. ServiceLabel = "com.docker.compose.service" )
Variables ¶
This section is empty.
Functions ¶
func LoadProject ¶
LoadProject loads a Docker Compose project from the given file paths and env files.
func ProjectName ¶
ProjectName returns the compose project name for a workspace. It respects the COMPOSE_PROJECT_NAME env var, falling back to "crib-<wsID>".
Types ¶
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper wraps the compose CLI for executing compose commands.
func NewHelper ¶
NewHelper detects the compose CLI and returns a Helper. It probes `<runtimeCommand> compose version --short` to verify availability.
func NewHelperFromRuntime ¶
NewHelperFromRuntime creates a Helper with the given runtime command without probing for compose availability. Useful for cases where only the runtime identity is needed (e.g. checking if Podman is in use).
func (*Helper) Build ¶
func (h *Helper) Build(ctx context.Context, projectName string, files []string, services []string, stdout, stderr io.Writer, extraEnv []string) error
Build runs `compose build` for the given project. extraEnv is appended to the subprocess environment for variable substitution.
func (*Helper) BuiltImageName ¶
BuiltImageName returns the expected image name for a compose-built service. The separator between project and service differs by compose provider: Docker Compose v2 uses "-", podman-compose uses "_".
func (*Helper) Down ¶
func (h *Helper) Down(ctx context.Context, projectName string, files []string, stdout, stderr io.Writer, extraEnv []string) error
Down runs `compose down` for the given project. extraEnv is appended to the subprocess environment for variable substitution.
func (*Helper) ListContainers ¶
func (h *Helper) ListContainers(ctx context.Context, projectName string, files []string, extraEnv []string) ([]string, error)
ListContainers returns the container IDs for a compose project. Returns only the IDs without any filtering or parsing.
func (*Helper) ListServiceStatuses ¶ added in v0.3.0
func (h *Helper) ListServiceStatuses(ctx context.Context, projectName string, files []string, extraEnv []string) ([]ServiceStatus, error)
ListServiceStatuses returns the status of all services in a compose project. Uses `compose ps --format json` to get service names and states.
func (*Helper) Logs ¶ added in v0.5.0
func (h *Helper) Logs(ctx context.Context, projectName string, files []string, follow bool, tail string, stdout, stderr io.Writer, extraEnv []string) error
Logs runs `compose logs` for the given project. extraEnv is appended to the subprocess environment for variable substitution.
func (*Helper) Restart ¶ added in v0.2.0
func (h *Helper) Restart(ctx context.Context, projectName string, files []string, stdout, stderr io.Writer, extraEnv []string) error
Restart runs `compose restart` for the given project. extraEnv is appended to the subprocess environment for variable substitution.
func (*Helper) Run ¶
func (h *Helper) Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer, extraEnv []string) error
Run executes a compose command with the given args and I/O streams. extraEnv is appended to the current process environment for the subprocess.
func (*Helper) RuntimeCommand ¶
RuntimeCommand returns the base runtime command (e.g. "docker" or "podman").
func (*Helper) Stop ¶
func (h *Helper) Stop(ctx context.Context, projectName string, files []string, stdout, stderr io.Writer, extraEnv []string) error
Stop runs `compose stop` for the given project. extraEnv is appended to the subprocess environment for variable substitution.
type PortBinding ¶ added in v0.4.0
PortBinding describes a published port mapping for a compose service.
type ServiceInfo ¶
type ServiceInfo struct {
// Image is the image reference for the service (empty if build-only).
Image string
// HasBuild is true when the service has a build section.
HasBuild bool
// BuildCtx is the absolute path to the build context directory.
BuildCtx string
// Dockerfile is the Dockerfile path (relative to BuildCtx).
Dockerfile string
// User is the user directive from the compose service.
User string
}
ServiceInfo holds extracted service configuration needed for feature builds.
func GetServiceInfo ¶
func GetServiceInfo(ctx context.Context, paths []string, serviceName string, env []string) (*ServiceInfo, error)
GetServiceInfo loads compose files and extracts configuration for the named service. env provides extra environment variables for ${VAR} substitution in compose files.
type ServiceStatus ¶ added in v0.3.0
type ServiceStatus struct {
Service string
State string
Ports []PortBinding
}
ServiceStatus holds the status of a single compose service.