Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
estroz committed Aug 19, 2019
1 parent 2a59005 commit d1f2408
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions doc/user/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e

// Return all pods in the request namespace with a label of `app=<name>`
// and is running.
podList := &v1.PodList{}
opts := []client.ListOption{
client.InNamespace(request.NamespacedName.Namespace),
client.MatchingLabels{"app", request.NamespacedName.Name},
client.MatchingField("status.phase", "Running"),
}
podList := &v1.PodList{}
ctx := context.TODO()
err := r.client.List(ctx, podList, opts...)

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

// Update the App status with the pod names.
// List the pods for this app's deployment.
podList := &corev1.PodList{}
listOpts := []client.ListOption{
client.InNamespace(app.Namespace),
client.MatchingLabels(labelsForApp(app.Name)),
}
podList := &corev1.PodList{}
if err = r.client.List(context.TODO(), podList, listOpts...); err != nil {
return reconcile.Result{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion example/memcached-operator/memcached_controller.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ func (r *ReconcileMemcached) Reconcile(request reconcile.Request) (reconcile.Res

// Update the Memcached status with the pod names
// List the pods for this memcached's deployment
podList := &corev1.PodList{}
listOpts := []client.ListOption{
client.InNamespace(memcached.Namespace),
client.MatchingLabels(labelsForApp(memcached.Name)),
}
podList := &corev1.PodList{}
if err = r.client.List(context.TODO(), podList, listOpts...); err != nil {
reqLogger.Error(err, "Failed to list pods", "Memcached.Namespace", memcached.Namespace, "Memcached.Name", memcached.Name)
return reconcile.Result{}, err
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/_incluster-test-code/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ func verifyLeader(t *testing.T, namespace string, f *framework.Framework, labels
owner := owners[0]

// get operator pods
pods := &v1.PodList{}
opts := []client.ListOption{
client.InNamespace(namespace),
client.MatchingLabels(labels),
client.MatchingField("status.phase", "Running"),
}
pods := &v1.PodList{}
err = f.Client.List(goctx.TODO(), pods, opts...)
if err != nil {
return nil, err
Expand Down Expand Up @@ -421,12 +421,12 @@ func memcachedOperatorMetricsTest(t *testing.T, f *framework.Framework, ctx *fra

func getMetrics(t *testing.T, f *framework.Framework, labels map[string]string, ns, port string) ([]byte, error) {
// Get operator pod
pods := &v1.PodList{}
opts := []client.ListOption{
client.InNamespace(ns),
client.MatchingLabels(labels),
client.MatchingField("status.phase", "Running"),
}
pods := &v1.PodList{}
err = f.Client.List(goctx.TODO(), pods, opts...)
if err != nil {
return nil, fmt.Errorf("failed to get pods: (%v)", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ func (r *ReconcileMemcached) Reconcile(request reconcile.Request) (reconcile.Res
// Update the Memcached status with the pod names
// List the pods for this memcached's deployment
podList := &corev1.PodList{}
listOps := []client.ListOption{
listOpts := []client.ListOption{
client.InNamespace(memcached.Namespace),
client.MatchingLabels(labelsForMemcached(memcached.Name)),
}
err = r.client.List(context.TODO(), podList, listOps...)
err = r.client.List(context.TODO(), podList, listOpts...)
if err != nil {
reqLogger.Error(err, "Failed to list pods.", "Memcached.Namespace", memcached.Namespace, "Memcached.Name", memcached.Name)
return reconcile.Result{}, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ func (r *ReconcileMemcachedRS) Reconcile(request reconcile.Request) (reconcile.R
// Update the Memcached status with the pod names
// List the pods for this memcached's replicaSet
podList := &corev1.PodList{}
listOps := []client.ListOption{
listOpts := []client.ListOption{
client.InNamespace(memcachedrs.Namespace),
client.MatchingLabels(labelsForMemcached(memcachedrs.Name)),
}
err = r.client.List(context.TODO(), podList, listOps...)
err = r.client.List(context.TODO(), podList, listOpts...)
if err != nil {
reqLogger.Error(err, "Failed to list pods", "Memcached.Namespace", memcachedrs.Namespace, "Memcached.Name", memcachedrs.Name)
return reconcile.Result{}, err
Expand Down

0 comments on commit d1f2408

Please sign in to comment.