Skip to content

Commit 8d0dc18

Browse files
committed
context consistency: ensure all context are TODO()
1 parent baafb49 commit 8d0dc18

File tree

10 files changed

+479
-26
lines changed

10 files changed

+479
-26
lines changed

pkg/controller/deployment/deployment_helper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func TestGetOverrideResourcesFor(t *testing.T) {
334334
},
335335
}
336336

337-
ctx, cancel := context.WithCancel(context.Background())
337+
ctx, cancel := context.WithCancel(context.TODO())
338338
defer cancel()
339339

340340
// Create channel to know when the watch has started.
@@ -856,7 +856,7 @@ func TestGetOverrideSchedulingFor(t *testing.T) {
856856
},
857857
}
858858

859-
ctx, cancel := context.WithCancel(context.Background())
859+
ctx, cancel := context.WithCancel(context.TODO())
860860
defer cancel()
861861

862862
// Create channel to know when the watch has started.

pkg/controller/istiocsr/certificates_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func TestCreateOrApplyCertificates(t *testing.T) {
217217
}
218218
r.ctrlClient = mock
219219
istiocsr := &v1alpha1.IstioCSR{}
220-
if err := r.Get(context.Background(), types.NamespacedName{
220+
if err := r.Get(context.TODO(), types.NamespacedName{
221221
Namespace: testIstioCSR().Namespace,
222222
Name: testIstioCSR().Name,
223223
}, istiocsr); err != nil {

pkg/controller/istiocsr/controller.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func New(mgr ctrl.Manager) (*Reconciler, error) {
6464
}
6565
return &Reconciler{
6666
ctrlClient: c,
67-
ctx: context.Background(),
67+
ctx: context.TODO(),
6868
eventRecorder: mgr.GetEventRecorderFor(ControllerName),
6969
log: ctrl.Log.WithName(ControllerName),
7070
scheme: mgr.GetScheme(),
@@ -111,43 +111,43 @@ func BuildCustomClient(mgr ctrl.Manager) (client.Client, error) {
111111
if err != nil {
112112
return nil, err
113113
}
114-
if _, err = customCache.GetInformer(context.Background(), &v1alpha1.IstioCSR{}); err != nil {
114+
if _, err = customCache.GetInformer(context.TODO(), &v1alpha1.IstioCSR{}); err != nil {
115115
return nil, err
116116
}
117-
if _, err = customCache.GetInformer(context.Background(), &certmanagerv1.Certificate{}); err != nil {
117+
if _, err = customCache.GetInformer(context.TODO(), &certmanagerv1.Certificate{}); err != nil {
118118
return nil, err
119119
}
120-
if _, err = customCache.GetInformer(context.Background(), &appsv1.Deployment{}); err != nil {
120+
if _, err = customCache.GetInformer(context.TODO(), &appsv1.Deployment{}); err != nil {
121121
return nil, err
122122
}
123-
if _, err = customCache.GetInformer(context.Background(), &rbacv1.ClusterRole{}); err != nil {
123+
if _, err = customCache.GetInformer(context.TODO(), &rbacv1.ClusterRole{}); err != nil {
124124
return nil, err
125125
}
126-
if _, err = customCache.GetInformer(context.Background(), &rbacv1.ClusterRoleBinding{}); err != nil {
126+
if _, err = customCache.GetInformer(context.TODO(), &rbacv1.ClusterRoleBinding{}); err != nil {
127127
return nil, err
128128
}
129-
if _, err = customCache.GetInformer(context.Background(), &rbacv1.Role{}); err != nil {
129+
if _, err = customCache.GetInformer(context.TODO(), &rbacv1.Role{}); err != nil {
130130
return nil, err
131131
}
132-
if _, err = customCache.GetInformer(context.Background(), &rbacv1.RoleBinding{}); err != nil {
132+
if _, err = customCache.GetInformer(context.TODO(), &rbacv1.RoleBinding{}); err != nil {
133133
return nil, err
134134
}
135-
if _, err = customCache.GetInformer(context.Background(), &corev1.Service{}); err != nil {
135+
if _, err = customCache.GetInformer(context.TODO(), &corev1.Service{}); err != nil {
136136
return nil, err
137137
}
138-
if _, err = customCache.GetInformer(context.Background(), &corev1.ServiceAccount{}); err != nil {
138+
if _, err = customCache.GetInformer(context.TODO(), &corev1.ServiceAccount{}); err != nil {
139139
return nil, err
140140
}
141-
if _, err = customCache.GetInformer(context.Background(), &corev1.Secret{}); err != nil {
141+
if _, err = customCache.GetInformer(context.TODO(), &corev1.Secret{}); err != nil {
142142
return nil, err
143143
}
144-
if _, err = customCache.GetInformer(context.Background(), &corev1.ConfigMap{}); err != nil {
144+
if _, err = customCache.GetInformer(context.TODO(), &corev1.ConfigMap{}); err != nil {
145145
return nil, err
146146
}
147-
if _, err = customCache.GetInformer(context.Background(), &certmanagerv1.Issuer{}); err != nil {
147+
if _, err = customCache.GetInformer(context.TODO(), &certmanagerv1.Issuer{}); err != nil {
148148
return nil, err
149149
}
150-
if _, err = customCache.GetInformer(context.Background(), &certmanagerv1.ClusterIssuer{}); err != nil {
150+
if _, err = customCache.GetInformer(context.TODO(), &certmanagerv1.ClusterIssuer{}); err != nil {
151151
return nil, err
152152
}
153153

pkg/controller/istiocsr/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func TestReconcile(t *testing.T) {
391391
}
392392
r.ctrlClient = mock
393393
istiocsr := testIstioCSR()
394-
result, err := r.Reconcile(context.Background(),
394+
result, err := r.Reconcile(context.TODO(),
395395
ctrl.Request{
396396
NamespacedName: types.NamespacedName{Name: istiocsr.GetName(), Namespace: istiocsr.GetNamespace()},
397397
},

pkg/controller/istiocsr/test_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var (
3636

3737
func testReconciler(t *testing.T) *Reconciler {
3838
return &Reconciler{
39-
ctx: context.Background(),
39+
ctx: context.TODO(),
4040
eventRecorder: record.NewFakeRecorder(100),
4141
log: testr.New(t),
4242
scheme: library.Scheme,

pkg/operator/informers/externalversions/factory.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)