@@ -27,25 +27,10 @@ import (
2727 cachev1alpha1 "github.com/kcp-dev/sdk/apis/cache/v1alpha1"
2828 conditionsv1alpha1 "github.com/kcp-dev/sdk/apis/third_party/conditions/apis/conditions/v1alpha1"
2929 "github.com/kcp-dev/sdk/apis/third_party/conditions/util/conditions"
30- topologyv1alpha1 "github.com/kcp-dev/sdk/apis/topology/v1alpha1"
3130)
3231
33- func (c * controller ) reconcile (ctx context.Context , endpoints * cachev1alpha1.CachedResourceEndpointSlice ) (bool , error ) {
34- r := & endpointsReconciler {
35- getCachedResource : c .getCachedResource ,
36- getPartition : c .getPartition ,
37- }
38-
39- return r .reconcile (ctx , endpoints )
40- }
41-
42- type endpointsReconciler struct {
43- getCachedResource func (path logicalcluster.Path , name string ) (* cachev1alpha1.CachedResource , error )
44- getPartition func (clusterName logicalcluster.Name , name string ) (* topologyv1alpha1.Partition , error )
45- }
46-
47- func (r * endpointsReconciler ) reconcile (ctx context.Context , endpoints * cachev1alpha1.CachedResourceEndpointSlice ) (bool , error ) {
48- _ , err := r .getCachedResource (logicalcluster .From (endpoints ).Path (), endpoints .Spec .CachedResource .Name )
32+ func (c * controller ) reconcile (ctx context.Context , endpoints * cachev1alpha1.CachedResourceEndpointSlice ) error {
33+ _ , err := c .getCachedResource (logicalcluster .From (endpoints ).Path (), endpoints .Spec .CachedResource .Name )
4934 if err != nil {
5035 if apierrors .IsNotFound (err ) {
5136 // Don't keep the endpoints if the CachedResource has been deleted.
@@ -60,7 +45,7 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
6045 endpoints .Spec .CachedResource .Name ,
6146 )
6247 // No need to try again.
63- return false , nil
48+ return nil
6449 } else {
6550 conditions .MarkFalse (
6651 endpoints ,
@@ -71,15 +56,15 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
7156 logicalcluster .From (endpoints ),
7257 endpoints .Spec .CachedResource .Name ,
7358 )
74- return true , err
59+ return err
7560 }
7661 }
7762 conditions .MarkTrue (endpoints , cachev1alpha1 .CachedResourceValid )
7863
7964 // Check the partition selector.
8065 var selector labels.Selector
8166 if endpoints .Spec .Partition != "" {
82- partition , err := r .getPartition (logicalcluster .From (endpoints ), endpoints .Spec .Partition )
67+ partition , err := c .getPartition (logicalcluster .From (endpoints ), endpoints .Spec .Partition )
8368 if err != nil {
8469 if apierrors .IsNotFound (err ) {
8570 // Don't keep the endpoints if the Partition has been deleted and is still referenced.
@@ -93,7 +78,7 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
9378 err ,
9479 )
9580 // No need to try again.
96- return false , nil
81+ return nil
9782 } else {
9883 conditions .MarkFalse (
9984 endpoints ,
@@ -103,7 +88,7 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
10388 "%v" ,
10489 err ,
10590 )
106- return true , err
91+ return err
10792 }
10893 }
10994 selector , err = metav1 .LabelSelectorAsSelector (partition .Spec .Selector )
@@ -116,7 +101,7 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
116101 "%v" ,
117102 err ,
118103 )
119- return true , err
104+ return err
120105 }
121106 }
122107 if selector == nil {
@@ -127,5 +112,5 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
127112
128113 endpoints .Status .ShardSelector = selector .String ()
129114
130- return true , err
115+ return nil
131116}
0 commit comments