mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +00:00
Report/render both image and container labels
Daemon labels will have to wait since the go client (Docker API v1.14) doesn't support them yet (daemon labels were exposed in Docker API v1.16) See https://godoc.org/github.com/fsouza/go-dockerclient#Client.Info for details.
This commit is contained in:
@@ -312,11 +312,7 @@ func containerOriginTable(nmd report.NodeMetadata, addHostTag bool) (Table, bool
|
||||
for _, ip := range docker.ExtractContainerIPs(nmd) {
|
||||
rows = append(rows, Row{Key: "IP Address", ValueMajor: ip, ValueMinor: ""})
|
||||
}
|
||||
|
||||
for labelKey, labelValue := range docker.ExtractContainerLabels(nmd) {
|
||||
rows = append(rows, Row{Key: fmt.Sprintf("Label %q", labelKey), ValueMajor: labelValue})
|
||||
|
||||
}
|
||||
rows = append(rows, getDockerLabelRows(nmd)...)
|
||||
|
||||
if val, ok := nmd.Metadata[docker.MemoryUsage]; ok {
|
||||
memory, err := strconv.ParseFloat(val, 64)
|
||||
@@ -354,6 +350,7 @@ func containerImageOriginTable(nmd report.NodeMetadata) (Table, bool) {
|
||||
rows = append(rows, Row{Key: tuple.human, ValueMajor: val, ValueMinor: ""})
|
||||
}
|
||||
}
|
||||
rows = append(rows, getDockerLabelRows(nmd)...)
|
||||
title := "Container Image"
|
||||
var (
|
||||
nameFound bool
|
||||
@@ -370,6 +367,21 @@ func containerImageOriginTable(nmd report.NodeMetadata) (Table, bool) {
|
||||
}, len(rows) > 0 || nameFound
|
||||
}
|
||||
|
||||
func getDockerLabelRows(nmd report.NodeMetadata) []Row {
|
||||
rows := []Row{}
|
||||
// Add labels in alphabetical order
|
||||
labels := docker.ExtractLabels(nmd)
|
||||
labelKeys := make([]string, 0, len(labels))
|
||||
for k := range labels {
|
||||
labelKeys = append(labelKeys, k)
|
||||
}
|
||||
sort.Strings(labelKeys)
|
||||
for _, labelKey := range labelKeys {
|
||||
rows = append(rows, Row{Key: fmt.Sprintf("Label %q", labelKey), ValueMajor: labels[labelKey]})
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
func hostOriginTable(nmd report.NodeMetadata) (Table, bool) {
|
||||
rows := []Row{}
|
||||
for _, tuple := range []struct{ key, human string }{
|
||||
|
||||
Reference in New Issue
Block a user