refactor dockersource container refresh into channel

This commit is contained in:
Bradley Cicenas
2017-03-05 06:46:41 +00:00
parent 8fb5c5de59
commit 3172f141f9
9 changed files with 85 additions and 100 deletions

View File

@@ -29,10 +29,9 @@ func (cs *MockContainerSource) Init() {
for i := 0; i < total; i++ {
collector := metrics.NewMock()
c := NewContainer(makeID(), makeName(), collector)
lock.Lock()
c := NewContainer(makeID(), collector)
c.SetName(makeName())
cs.containers = append(cs.containers, c)
lock.Unlock()
c.SetState(makeState())
}
@@ -74,8 +73,6 @@ func (cs *MockContainerSource) delByID(id string) {
// Remove one or more containers by index
func (cs *MockContainerSource) del(idx ...int) {
lock.Lock()
defer lock.Unlock()
for _, i := range idx {
cs.containers = append(cs.containers[:i], cs.containers[i+1:]...)
}