cert-manager/pkg/util/context.go
2017-09-21 20:26:27 +01:00

18 lines
265 B
Go

package util
import (
"context"
)
func ContextWithStopCh(ctx context.Context, stopCh <-chan struct{}) context.Context {
ctx, cancel := context.WithCancel(ctx)
go func() {
defer cancel()
select {
case <-ctx.Done():
case <-stopCh:
}
}()
return ctx
}