MCPcopy
hub / github.com/docker/compose / NewContainerFormat

Function NewContainerFormat

cmd/formatter/container.go:48–83  ·  view source on GitHub ↗

NewContainerFormat returns a Format for rendering using a Context

(source string, quiet bool, size bool)

Source from the content-addressed store, hash-verified

46
47// NewContainerFormat returns a Format for rendering using a Context
48func NewContainerFormat(source string, quiet bool, size bool) formatter.Format {
49 switch source {
50 case formatter.TableFormatKey, "": // table formatting is the default if none is set.
51 if quiet {
52 return formatter.DefaultQuietFormat
53 }
54 format := defaultContainerTableFormat
55 if size {
56 format += `\t{{.Size}}`
57 }
58 return formatter.Format(format)
59 case formatter.RawFormatKey:
60 if quiet {
61 return `container_id: {{.ID}}`
62 }
63 format := `container_id: {{.ID}}
64image: {{.Image}}
65command: {{.Command}}
66created_at: {{.CreatedAt}}
67state: {{- pad .State 1 0}}
68status: {{- pad .Status 1 0}}
69names: {{.Names}}
70labels: {{- pad .Labels 1 0}}
71ports: {{- pad .Ports 1 0}}
72`
73 if size {
74 format += `size: {{.Size}}\n`
75 }
76 return formatter.Format(format)
77 default: // custom format
78 if quiet {
79 return formatter.DefaultQuietFormat
80 }
81 return formatter.Format(source)
82 }
83}
84
85// ContainerWrite renders the context for a list of containers
86func ContainerWrite(ctx formatter.Context, containers []api.ContainerSummary) error {

Callers 1

runPsFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected