Skip to content

Commit d1f2408

Browse files
committed
more updates
1 parent 2a59005 commit d1f2408

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

doc/user/client.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
155155

156156
// Return all pods in the request namespace with a label of `app=<name>`
157157
// and is running.
158+
podList := &v1.PodList{}
158159
opts := []client.ListOption{
159160
client.InNamespace(request.NamespacedName.Namespace),
160161
client.MatchingLabels{"app", request.NamespacedName.Name},
161162
client.MatchingField("status.phase", "Running"),
162163
}
163-
podList := &v1.PodList{}
164164
ctx := context.TODO()
165165
err := r.client.List(ctx, podList, opts...)
166166

@@ -371,11 +371,11 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
371371

372372
// Update the App status with the pod names.
373373
// List the pods for this app's deployment.
374+
podList := &corev1.PodList{}
374375
listOpts := []client.ListOption{
375376
client.InNamespace(app.Namespace),
376377
client.MatchingLabels(labelsForApp(app.Name)),
377378
}
378-
podList := &corev1.PodList{}
379379
if err = r.client.List(context.TODO(), podList, listOpts...); err != nil {
380380
return reconcile.Result{}, err
381381
}

example/memcached-operator/memcached_controller.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ func (r *ReconcileMemcached) Reconcile(request reconcile.Request) (reconcile.Res
141141

142142
// Update the Memcached status with the pod names
143143
// List the pods for this memcached's deployment
144+
podList := &corev1.PodList{}
144145
listOpts := []client.ListOption{
145146
client.InNamespace(memcached.Namespace),
146147
client.MatchingLabels(labelsForApp(memcached.Name)),
147148
}
148-
podList := &corev1.PodList{}
149149
if err = r.client.List(context.TODO(), podList, listOpts...); err != nil {
150150
reqLogger.Error(err, "Failed to list pods", "Memcached.Namespace", memcached.Namespace, "Memcached.Name", memcached.Name)
151151
return reconcile.Result{}, err

test/e2e/_incluster-test-code/memcached_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ func verifyLeader(t *testing.T, namespace string, f *framework.Framework, labels
137137
owner := owners[0]
138138

139139
// get operator pods
140+
pods := &v1.PodList{}
140141
opts := []client.ListOption{
141142
client.InNamespace(namespace),
142143
client.MatchingLabels(labels),
143144
client.MatchingField("status.phase", "Running"),
144145
}
145-
pods := &v1.PodList{}
146146
err = f.Client.List(goctx.TODO(), pods, opts...)
147147
if err != nil {
148148
return nil, err
@@ -421,12 +421,12 @@ func memcachedOperatorMetricsTest(t *testing.T, f *framework.Framework, ctx *fra
421421

422422
func getMetrics(t *testing.T, f *framework.Framework, labels map[string]string, ns, port string) ([]byte, error) {
423423
// Get operator pod
424+
pods := &v1.PodList{}
424425
opts := []client.ListOption{
425426
client.InNamespace(ns),
426427
client.MatchingLabels(labels),
427428
client.MatchingField("status.phase", "Running"),
428429
}
429-
pods := &v1.PodList{}
430430
err = f.Client.List(goctx.TODO(), pods, opts...)
431431
if err != nil {
432432
return nil, fmt.Errorf("failed to get pods: (%v)", err)

test/test-framework/pkg/controller/memcached/memcached_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ func (r *ReconcileMemcached) Reconcile(request reconcile.Request) (reconcile.Res
150150
// Update the Memcached status with the pod names
151151
// List the pods for this memcached's deployment
152152
podList := &corev1.PodList{}
153-
listOps := []client.ListOption{
153+
listOpts := []client.ListOption{
154154
client.InNamespace(memcached.Namespace),
155155
client.MatchingLabels(labelsForMemcached(memcached.Name)),
156156
}
157-
err = r.client.List(context.TODO(), podList, listOps...)
157+
err = r.client.List(context.TODO(), podList, listOpts...)
158158
if err != nil {
159159
reqLogger.Error(err, "Failed to list pods.", "Memcached.Namespace", memcached.Namespace, "Memcached.Name", memcached.Name)
160160
return reconcile.Result{}, err

test/test-framework/pkg/controller/memcachedrs/memcachedrs_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ func (r *ReconcileMemcachedRS) Reconcile(request reconcile.Request) (reconcile.R
152152
// Update the Memcached status with the pod names
153153
// List the pods for this memcached's replicaSet
154154
podList := &corev1.PodList{}
155-
listOps := []client.ListOption{
155+
listOpts := []client.ListOption{
156156
client.InNamespace(memcachedrs.Namespace),
157157
client.MatchingLabels(labelsForMemcached(memcachedrs.Name)),
158158
}
159-
err = r.client.List(context.TODO(), podList, listOps...)
159+
err = r.client.List(context.TODO(), podList, listOpts...)
160160
if err != nil {
161161
reqLogger.Error(err, "Failed to list pods", "Memcached.Namespace", memcachedrs.Namespace, "Memcached.Name", memcachedrs.Name)
162162
return reconcile.Result{}, err

0 commit comments

Comments
 (0)