mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-19 04:16:21 +00:00
Review feedback
This commit is contained in:
@@ -71,6 +71,7 @@ type Container interface {
|
||||
ID() string
|
||||
Image() string
|
||||
PID() int
|
||||
Hostname() string
|
||||
GetNode([]net.IP) report.Node
|
||||
|
||||
StartGatheringStats() error
|
||||
@@ -101,6 +102,15 @@ func (c *container) PID() int {
|
||||
return c.container.State.Pid
|
||||
}
|
||||
|
||||
func (c *container) Hostname() string {
|
||||
if c.container.Config.Domainname == "" {
|
||||
return c.container.Config.Hostname
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s.%s", c.container.Config.Hostname,
|
||||
c.container.Config.Domainname)
|
||||
}
|
||||
|
||||
func (c *container) StartGatheringStats() error {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
@@ -222,7 +232,7 @@ func (c *container) GetNode(localAddrs []net.IP) report.Node {
|
||||
ImageID: c.container.Image,
|
||||
ContainerIPs: strings.Join(append(c.container.NetworkSettings.SecondaryIPAddresses,
|
||||
c.container.NetworkSettings.IPAddress), " "),
|
||||
ContainerHostname: c.container.Config.Hostname,
|
||||
ContainerHostname: c.Hostname(),
|
||||
})
|
||||
AddLabels(result, c.container.Config.Labels)
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@ func (c *mockContainer) Image() string {
|
||||
return c.c.Image
|
||||
}
|
||||
|
||||
func (c *mockContainer) Hostname() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *mockContainer) StartGatheringStats() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
+3
-2
@@ -484,7 +484,7 @@ func MapContainer2ContainerImage(n RenderableNode, _ report.Networks) Renderable
|
||||
return RenderableNodes{}
|
||||
}
|
||||
|
||||
// Add container-<id> key to NMD, which will later be counted to produce the minor label
|
||||
// Add container id key to the counters, which will later be counted to produce the minor label
|
||||
result := NewDerivedNode(id, n)
|
||||
result.Node.Counters[containersKey] = 1
|
||||
return RenderableNodes{id: result}
|
||||
@@ -608,10 +608,11 @@ func MapContainer2Hostname(n RenderableNode, _ report.Networks) RenderableNodes
|
||||
return RenderableNodes{}
|
||||
}
|
||||
|
||||
// Add container-<id> key to NMD, which will later be counted to produce the minor label
|
||||
result := NewDerivedNode(id, n)
|
||||
result.LabelMajor = id
|
||||
result.Rank = id
|
||||
|
||||
// Add container id key to the counters, which will later be counted to produce the minor label
|
||||
result.Node.Counters[containersKey] = 1
|
||||
return RenderableNodes{id: result}
|
||||
}
|
||||
|
||||
+2
-11
@@ -176,17 +176,8 @@ var ContainerImageRenderer = Map{
|
||||
var ContainerHostnameRenderer = Map{
|
||||
MapFunc: MapCountContainers,
|
||||
Renderer: Map{
|
||||
MapFunc: MapContainer2Hostname,
|
||||
Renderer: MakeReduce(
|
||||
Map{
|
||||
MapFunc: MapContainer2ContainerImage,
|
||||
Renderer: ContainerRenderer,
|
||||
},
|
||||
Map{
|
||||
MapFunc: MapContainerImageIdentity,
|
||||
Renderer: SelectContainerImage,
|
||||
},
|
||||
),
|
||||
MapFunc: MapContainer2Hostname,
|
||||
Renderer: ContainerRenderer,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user