parent
1a3c40a1d3
commit
94cd7114f8
@ -71,6 +71,13 @@ type ContainerReference struct {
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
}
|
||||
|
||||
// Sorts by container name.
|
||||
type ContainerReferenceSlice []ContainerReference
|
||||
|
||||
func (self ContainerReferenceSlice) Len() int { return len(self) }
|
||||
func (self ContainerReferenceSlice) Swap(i, j int) { self[i], self[j] = self[j], self[i] }
|
||||
func (self ContainerReferenceSlice) Less(i, j int) bool { return self[i].Name < self[j].Name }
|
||||
|
||||
// ContainerInfoQuery is used when users check a container info from the REST api.
|
||||
// It specifies how much data users want to get about a container
|
||||
type ContainerInfoRequest struct {
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -319,6 +320,7 @@ func (c *containerData) updateStats() error {
|
||||
}
|
||||
|
||||
func (c *containerData) updateSubcontainers() error {
|
||||
var subcontainers info.ContainerReferenceSlice
|
||||
subcontainers, err := c.handler.ListContainers(container.ListSelf)
|
||||
if err != nil {
|
||||
// Ignore errors if the container is dead.
|
||||
@ -327,6 +329,7 @@ func (c *containerData) updateSubcontainers() error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
sort.Sort(subcontainers)
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
c.info.Subcontainers = subcontainers
|
||||
|
Loading…
Reference in New Issue
Block a user