github.com/SupersunnySea/draft@v0.16.0/pkg/kube/podutil/stop.go (about) 1 package podutil 2 3 import "sync" 4 5 // needed so that we only attempt to close the channel once 6 // used when watching for pods to be ready 7 type stopChan struct { 8 c chan struct{} 9 sync.Once 10 } 11 12 func newStopChan() *stopChan { 13 return &stopChan{c: make(chan struct{})} 14 } 15 16 func (s *stopChan) closeOnce() { 17 s.Do(func() { 18 close(s.c) 19 }) 20 }