MCPcopy Index your code
hub / github.com/docker/cli / Names

Method Names

cli/command/formatter/container.go:147–168  ·  view source on GitHub ↗

Names returns a comma-separated string of the container's names, with their slash (/) prefix stripped. Additional names for the container (related to the legacy `--link` feature) are omitted when formatting "truncated".

()

Source from the content-addressed store, hash-verified

145// slash (/) prefix stripped. Additional names for the container (related to the
146// legacy `--link` feature) are omitted when formatting "truncated".
147func (c *ContainerContext) Names() string {
148 var b strings.Builder
149 for i, n := range c.c.Names {
150 name := strings.TrimPrefix(n, "/")
151 if c.trunc {
152 // When printing truncated, we only print a single name.
153 //
154 // Pick the first name that's not a legacy link (does not have
155 // slashes inside the name itself (e.g., "/other-container/link")).
156 // Normally this would be the first name found.
157 if strings.IndexByte(name, '/') == -1 {
158 return name
159 }
160 continue
161 }
162 if i > 0 {
163 b.WriteByte(',')
164 }
165 b.WriteString(name)
166 }
167 return b.String()
168}
169
170// StripNamePrefix removes any "/" prefix from container names returned
171// by the "ContainersList" API.

Callers 2

completeContextNamesFunction · 0.80
completeContextNamesFunction · 0.80

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected