Documentation
¶
Index ¶
- func BuildCleanCommandArgs(services []string, profiles ...string) (rmArgs, buildArgs, upArgs []string)
- func BuildRestartCommandArgs(services []string, profiles ...string) (stopArgs, upArgs []string)
- func GetContainers() ([]string, error)
- func GetServices(projectDir string, profiles ...string) ([]string, error)
- func RunCommand(projectDir string, args ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCleanCommandArgs ¶
func BuildCleanCommandArgs(services []string, profiles ...string) (rmArgs, buildArgs, upArgs []string)
BuildCleanCommandArgs builds docker compose arguments for clean operation.
- upArgs: arguments to start the services detached (`compose up -d ...`)
func BuildRestartCommandArgs ¶
BuildRestartCommandArgs builds docker compose arguments for restart operation. BuildRestartCommandArgs builds Docker Compose argument lists to stop then start the specified services, injecting each provided profile as a `--profile <name>` flag immediately after `compose`. The first returned slice is the arguments for `docker compose stop <services>`; the second is for `docker compose up -d <services>`.
func GetContainers ¶
GetContainers returns the names of running Docker containers. It runs `docker ps --format "{{.Names}}"`, splits the output by newline, filters out empty names, and returns the resulting slice. An error is returned if the `docker` command fails.
func GetServices ¶
GetServices retrieves a list of services from docker-compose config. GetServices runs `docker compose config --services` in the specified project directory and returns the configured service names. If profiles are provided they are passed as `--profile <name>` flags to the compose command. The command output is split on whitespace to produce the returned service name slice. If the docker command fails, an error is returned.
func RunCommand ¶
RunCommand executes a Docker command with the given arguments in the specified project directory. RunCommand runs the specified docker subcommand with args inside projectDir and streams stdout and stderr to the current terminal. It returns an error wrapping the underlying execution failure if the docker process exits with a non-zero status.
Types ¶
This section is empty.