composeclient

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package composeclient talks to a Compose project through the Compose SDK. It does not shell out to `docker compose`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerLines

func ContainerLines(rows []composeapi.ContainerSummary) (roll StateDetail, children []ContainerLine)

ContainerLines rolls container rows into a project state and one line each. State strings are running, exited, and gone.

func Load

func Load(ctx context.Context, dir string, files []string, projectName string) (*types.Project, error)

Load reads a compose project. An empty dir is the current directory. An empty files list discovers compose.yaml, compose.yml, docker-compose.yml, and docker-compose.yaml in that directory (and a parent, which is compose-go's walk). projectName is applied only when it is non-empty; a file that sets `name:` is left alone.

func Narrow

func Narrow(p *types.Project, services []string) (*types.Project, error)

Narrow limits the project to services. An empty list returns p unchanged. The default dependency set includes depends_on. An unknown service is the error from WithSelectedServices; the caller wraps it.

Types

type Client

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

Client is one Compose SDK session.

func New

func New(ctx context.Context) (*Client, error)

New connects a Compose service to the local Docker CLI defaults. A canceled ctx returns before Initialize finishes. The default prompt is left in place (it returns the suggested default).

func (*Client) Containers

func (c *Client) Containers(ctx context.Context, project *types.Project) ([]composeapi.ContainerSummary, error)

Containers lists running and exited containers.

func (*Client) Down

func (c *Client) Down(ctx context.Context, project *types.Project) error

Down stops the project. Volumes are kept. A narrowed project is the whole down set.

func (*Client) EnrichCommands

func (c *Client) EnrichCommands(ctx context.Context, children []ContainerLine)

EnrichCommands fills Command on running container lines from docker inspect Path.

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, project *types.Project, service string, tail int, follow bool, w io.Writer) error

Logs writes container output to w. tail < 0 requests every line. A non-empty service limits the stream to that compose service.

func (*Client) Up

func (c *Client) Up(ctx context.Context, project *types.Project) error

Up starts the project and returns after the containers are started. Build is set so an image-less service is built. An empty recreate policy recreates only when the config hash or image digest changed.

type ContainerLine

type ContainerLine struct {
	ID, State, Detail string
	ContainerID       string
	Command           string
}

ContainerLine is one container row. ID is the compose service, or service#n when that service appears more than once.

type StateDetail

type StateDetail struct {
	State  string
	Detail string
}

StateDetail is a rollup of one compose project.

Jump to

Keyboard shortcuts

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