traefik/vendor/github.com/docker/libcompose/project/info.go
Vincent Demeester b7daa2f3a4 Update traefik dependencies (docker/docker and related) (#1823)
Update traefik dependencies (docker/docker and related)

- Update dependencies
- Fix compilation problems
- Remove vdemeester/docker-events (in docker api now)
- Remove `integration/vendor`
- Use `testImport`
- update some deps.
- regenerate the lock from scratch (after a `glide cc`)
2017-07-06 16:28:13 +02:00

48 lines
955 B
Go

package project
import (
"bytes"
"io"
"text/tabwriter"
)
// InfoSet holds a list of Info.
type InfoSet []Info
// Info holds a list of InfoPart.
type Info map[string]string
func (infos InfoSet) String(columns []string, titleFlag bool) string {
//no error checking, none of this should fail
buffer := bytes.NewBuffer(make([]byte, 0, 1024))
tabwriter := tabwriter.NewWriter(buffer, 4, 4, 2, ' ', 0)
first := true
for _, info := range infos {
if first && titleFlag {
writeLine(tabwriter, columns, true, info)
}
first = false
writeLine(tabwriter, columns, false, info)
}
tabwriter.Flush()
return buffer.String()
}
func writeLine(writer io.Writer, columns []string, key bool, info Info) {
first := true
for _, column := range columns {
if !first {
writer.Write([]byte{'\t'})
}
first = false
if key {
writer.Write([]byte(column))
} else {
writer.Write([]byte(info[column]))
}
}
writer.Write([]byte{'\n'})
}