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".
()
| 145 | // slash (/) prefix stripped. Additional names for the container (related to the |
| 146 | // legacy `--link` feature) are omitted when formatting "truncated". |
| 147 | func (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. |
no test coverage detected