in internal/stackdiag.go [122:147]
func newDiagJobState(k *Kubectl, ns string, verbose bool, image string, jobTimeout time.Duration, stopCh chan struct{}) *diagJobState {
ctx, cancelFunc := context.WithCancel(context.Background())
factory := informers.NewSharedInformerFactoryWithOptions(
k,
jobPollingInterval,
informers.WithNamespace(ns),
informers.WithTweakListOptions(func(options *metav1.ListOptions) {
options.LabelSelector = "app.kubernetes.io/name=eck-diagnostics"
}))
state := &diagJobState{
jobs: map[string]*diagJob{},
ns: ns,
kubectl: k,
informer: factory.Core().V1().Pods().Informer(),
cancelFunc: cancelFunc,
context: ctx,
verbose: verbose,
diagnosticImage: image,
jobTimeout: jobTimeout,
}
go func() {
<-stopCh
cancelFunc()
}()
return state
}