Skip to content

Add template formatting to compose ls and images#13952

Open
scarab-systems wants to merge 1 commit into
docker:mainfrom
scarab-systems:scarab-systems/compose-12948-format-template
Open

Add template formatting to compose ls and images#13952
scarab-systems wants to merge 1 commit into
docker:mainfrom
scarab-systems:scarab-systems/compose-12948-format-template

Conversation

@scarab-systems

@scarab-systems scarab-systems commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Closes #12948.

Description

This adds Docker CLI-style Go template formatting to docker compose ls and docker compose images.

Both commands already had a --format flag, but they were still routed through Compose's older table/json formatter path while sibling commands such as docker compose ps use Docker CLI template formatting. This PR adds typed formatter contexts for Compose project rows and Compose image rows, then routes custom templates through the Docker CLI formatter.

The existing --format json behavior is intentionally preserved as the current Compose JSON array output, to avoid changing that output shape for existing consumers. Template JSON remains available through templates such as --format '{{json .}}'. If maintainers prefer --format json to be aligned with the per-row Docker CLI output as part of this feature, I am happy to adjust.

Testing

  • gofmt -s -w cmd/compose/list.go cmd/compose/images.go cmd/formatter/formats.go cmd/formatter/project.go cmd/formatter/image.go cmd/formatter/compose_format_test.go
  • go test ./cmd/...

Disclosure: This PR was prepared with AI assistance under human direction and review.

Support Docker CLI-style Go templates for docker compose ls and docker compose images while keeping existing table and json output paths available.

The formatter contexts expose the fields already shown by those commands and add coverage for custom templates plus json template rendering.

Tests:
- gofmt -s -w cmd/compose/list.go cmd/compose/images.go cmd/formatter/formats.go cmd/formatter/project.go cmd/formatter/image.go cmd/formatter/compose_format_test.go
- GOTMPDIR=/workspace/workspace-compose-12948-20260719-01/cache/go-tmp go test ./cmd/...

Signed-off-by: Scarab Systems <scarab.systems@yahoo.com>
@scarab-systems
scarab-systems requested review from a team as code owners July 19, 2026 21:46
@scarab-systems
scarab-systems requested review from glours and ndeloof July 19, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Add GO templating capabilities to images and/or list commands

1 participant