Skip to content

Commit

Permalink
Minor modification
Browse files Browse the repository at this point in the history
  • Loading branch information
Sedef committed Jul 28, 2020
1 parent f0022c8 commit f9985e0
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions exp/addons/controllers/clusterresourceset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ import (
"context"
"encoding/base64"
"fmt"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
"sort"
"time"

"github.com/go-logr/logr"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -120,7 +119,6 @@ func (r *ClusterResourceSetReconciler) Reconcile(req ctrl.Request) (_ ctrl.Resul
return ctrl.Result{}, err
}


// Initialize the patch helper.
patchHelper, err := patch.NewHelper(clusterResourceSet, r.Client)
if err != nil {
Expand Down Expand Up @@ -415,20 +413,16 @@ func (r *ClusterResourceSetReconciler) clusterToClusterResourceSet(o handler.Map
// resourceToClusterResourceSet is mapper function that maps resources to ClusterResourceSet
func (r *ClusterResourceSetReconciler) resourceToClusterResourceSet(o handler.MapObject) []ctrl.Request {
result := []ctrl.Request{}
acc, err := meta.Accessor(o.Object)
if err != nil {
return nil
}

crsList := &addonsv1.ClusterResourceSetList{}
if err := r.Client.List(context.Background(), crsList, client.InNamespace(acc.GetNamespace())); err != nil {
if err := r.Client.List(context.Background(), crsList, client.InNamespace(o.Meta.GetNamespace())); err != nil {
return nil
}

for _, crs := range crsList.Items {
for _, resource := range crs.Spec.Resources {
if resource.Kind == o.Object.GetObjectKind().GroupVersionKind().Kind && crs.Name == acc.GetName() {
name := client.ObjectKey{Namespace: acc.GetNamespace(), Name: crs.Name}
if resource.Kind == o.Object.GetObjectKind().GroupVersionKind().Kind && crs.Name == o.Meta.GetName() {
name := client.ObjectKey{Namespace: o.Meta.GetNamespace(), Name: crs.Name}
result = append(result, ctrl.Request{NamespacedName: name})
break
}
Expand Down

0 comments on commit f9985e0

Please sign in to comment.