Skip to content

Commit

Permalink
change back to pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed May 20, 2021
1 parent a2b6fc7 commit bf13970
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func destroyLab(ctx context.Context, c *clab.CLab) (err error) {
}

log.Infof("Destroying lab: %s", c.Config.Name)
ctrChan := make(chan types.GenericContainer)
ctrChan := make(chan *types.GenericContainer)
wg := new(sync.WaitGroup)
wg.Add(int(maxWorkers))
for i := uint(0); i < maxWorkers; i++ {
Expand All @@ -197,10 +197,14 @@ func destroyLab(ctx context.Context, c *clab.CLab) (err error) {
for {
select {
case cont := <-ctrChan:
if cont.ID == "" {
if cont == nil {
log.Debugf("Worker %d terminating...", i)
return
}
name := strings.TrimLeft(cont.Names[0], "/")
name := cont.ID
if len(cont.Names) > 0 {
name = strings.TrimLeft(cont.Names[0], "/")
}
err := c.Runtime.DeleteContainer(ctx, name)
if err != nil {
log.Errorf("could not remove container '%s': %v", name, err)
Expand All @@ -212,7 +216,8 @@ func destroyLab(ctx context.Context, c *clab.CLab) (err error) {
}(i)
}
for _, ctr := range containers {
ctrChan <- ctr
ctr := ctr
ctrChan <- &ctr
}
close(ctrChan)

Expand Down

0 comments on commit bf13970

Please sign in to comment.