@@ -28,25 +28,10 @@ import (
2828 cachev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/cache/v1alpha1"
2929 conditionsv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/third_party/conditions/apis/conditions/v1alpha1"
3030 "github.com/kcp-dev/kcp/sdk/apis/third_party/conditions/util/conditions"
31- topologyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/topology/v1alpha1"
3231)
3332
34- func (c * controller ) reconcile (ctx context.Context , endpoints * cachev1alpha1.CachedResourceEndpointSlice ) (bool , error ) {
35- r := & endpointsReconciler {
36- getCachedResource : c .getCachedResource ,
37- getPartition : c .getPartition ,
38- }
39-
40- return r .reconcile (ctx , endpoints )
41- }
42-
43- type endpointsReconciler struct {
44- getCachedResource func (path logicalcluster.Path , name string ) (* cachev1alpha1.CachedResource , error )
45- getPartition func (clusterName logicalcluster.Name , name string ) (* topologyv1alpha1.Partition , error )
46- }
47-
48- func (r * endpointsReconciler ) reconcile (ctx context.Context , endpoints * cachev1alpha1.CachedResourceEndpointSlice ) (bool , error ) {
49- _ , err := r .getCachedResource (logicalcluster .From (endpoints ).Path (), endpoints .Spec .CachedResource .Name )
33+ func (c * controller ) reconcile (ctx context.Context , endpoints * cachev1alpha1.CachedResourceEndpointSlice ) error {
34+ _ , err := c .getCachedResource (logicalcluster .From (endpoints ).Path (), endpoints .Spec .CachedResource .Name )
5035 if err != nil {
5136 if apierrors .IsNotFound (err ) {
5237 // Don't keep the endpoints if the CachedResource has been deleted.
@@ -61,7 +46,7 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
6146 endpoints .Spec .CachedResource .Name ,
6247 )
6348 // No need to try again.
64- return false , nil
49+ return nil
6550 } else {
6651 conditions .MarkFalse (
6752 endpoints ,
@@ -72,15 +57,15 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
7257 logicalcluster .From (endpoints ),
7358 endpoints .Spec .CachedResource .Name ,
7459 )
75- return true , err
60+ return err
7661 }
7762 }
7863 conditions .MarkTrue (endpoints , cachev1alpha1 .CachedResourceValid )
7964
8065 // Check the partition selector.
8166 var selector labels.Selector
8267 if endpoints .Spec .Partition != "" {
83- partition , err := r .getPartition (logicalcluster .From (endpoints ), endpoints .Spec .Partition )
68+ partition , err := c .getPartition (logicalcluster .From (endpoints ), endpoints .Spec .Partition )
8469 if err != nil {
8570 if apierrors .IsNotFound (err ) {
8671 // Don't keep the endpoints if the Partition has been deleted and is still referenced.
@@ -94,7 +79,7 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
9479 err ,
9580 )
9681 // No need to try again.
97- return false , nil
82+ return nil
9883 } else {
9984 conditions .MarkFalse (
10085 endpoints ,
@@ -104,7 +89,7 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
10489 "%v" ,
10590 err ,
10691 )
107- return true , err
92+ return err
10893 }
10994 }
11095 selector , err = metav1 .LabelSelectorAsSelector (partition .Spec .Selector )
@@ -117,7 +102,7 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
117102 "%v" ,
118103 err ,
119104 )
120- return true , err
105+ return err
121106 }
122107 }
123108 if selector == nil {
@@ -128,5 +113,5 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, endpoints *cachev1a
128113
129114 endpoints .Status .ShardSelector = selector .String ()
130115
131- return true , err
116+ return nil
132117}
0 commit comments