Add template formatting to compose ls and images#13952
Open
scarab-systems wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12948.
Description
This adds Docker CLI-style Go template formatting to
docker compose lsanddocker compose images.Both commands already had a
--formatflag, but they were still routed through Compose's older table/json formatter path while sibling commands such asdocker compose psuse 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 jsonbehavior 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 jsonto 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.gogo test ./cmd/...Disclosure: This PR was prepared with AI assistance under human direction and review.