@@ -87,7 +87,7 @@ func (h *Handlerv20250312) HandleInitial(ctx context.Context, cluster *akov2gene
8787 return result .Error (state .StateInitial , fmt .Errorf ("failed to create cluster: %w" , err ))
8888 }
8989
90- err = h .patchStatus (ctx , cluster , response )
90+ err = h .patchStatus (ctx , cluster , response , deps ... )
9191 if err != nil {
9292 return result .Error (state .StateInitial , err )
9393 }
@@ -121,7 +121,7 @@ func (h *Handlerv20250312) HandleImportRequested(ctx context.Context, cluster *a
121121 return result .Error (state .StateImportRequested , fmt .Errorf ("failed to get Cluster with id %s: %w" , id , err ))
122122 }
123123
124- err = h .patchStatus (ctx , cluster , response )
124+ err = h .patchStatus (ctx , cluster , response , deps ... )
125125 if err != nil {
126126 return result .Error (state .StateImportRequested , fmt .Errorf ("failed to patch Cluster status: %w" , err ))
127127 }
@@ -155,7 +155,7 @@ func (h *Handlerv20250312) HandleCreating(ctx context.Context, cluster *akov2gen
155155 return result .Error (state .StateCreating , fmt .Errorf ("failed to get Cluster with name %s: %w" , params .ClusterName , err ))
156156 }
157157
158- return h .handleAtlasClusterState (ctx , cluster , atlasCluster , state .StateCreating , state .StateCreated )
158+ return h .handleAtlasClusterState (ctx , cluster , atlasCluster , state .StateCreating , state .StateCreated , deps ... )
159159}
160160
161161// HandleCreated handles the created state for version v20250312
@@ -184,7 +184,7 @@ func (h *Handlerv20250312) HandleUpdating(ctx context.Context, cluster *akov2gen
184184 return result .Error (state .StateUpdating , fmt .Errorf ("failed to get Cluster with name %s: %w" , params .ClusterName , err ))
185185 }
186186
187- return h .handleAtlasClusterState (ctx , cluster , atlasCluster , state .StateUpdating , state .StateUpdated )
187+ return h .handleAtlasClusterState (ctx , cluster , atlasCluster , state .StateUpdating , state .StateUpdated , deps ... )
188188}
189189
190190// HandleUpdated handles the updated state for version v20250312
@@ -250,7 +250,7 @@ func (h *Handlerv20250312) HandleDeleting(ctx context.Context, cluster *akov2gen
250250 return result .Error (state .StateDeletionRequested , fmt .Errorf ("failed to delete Cluster: %w" , err ))
251251 }
252252
253- return h .handleAtlasClusterState (ctx , cluster , atlasCluster , state .StateDeleting , state .StateDeleted )
253+ return h .handleAtlasClusterState (ctx , cluster , atlasCluster , state .StateDeleting , state .StateDeleted , deps ... )
254254}
255255
256256func (h * Handlerv20250312 ) handleUpserted (ctx context.Context , currentState state.ResourceState , cluster * akov2generated.Cluster ) (ctrlstate.Result , error ) {
@@ -293,7 +293,7 @@ func (h *Handlerv20250312) handleUpserted(ctx context.Context, currentState stat
293293 return result .Error (currentState , err )
294294 }
295295
296- err = h .patchStatus (ctx , cluster , response )
296+ err = h .patchStatus (ctx , cluster , response , deps ... )
297297 if err != nil {
298298 return result .Error (currentState , err )
299299 }
@@ -312,31 +312,21 @@ func (h *Handlerv20250312) SetupWithManager(_ controllerruntime.Manager, _ recon
312312 return nil
313313}
314314
315- func (h * Handlerv20250312 ) patchStatus (ctx context.Context , cluster * akov2generated.Cluster , atlasCluster * v20250312sdk.ClusterDescription20240805 ) error {
315+ func (h * Handlerv20250312 ) patchStatus (ctx context.Context , cluster * akov2generated.Cluster , atlasCluster * v20250312sdk.ClusterDescription20240805 , deps ... client. Object ) error {
316316 clusterCopy := cluster .DeepCopy ()
317317 _ , err := h .translator .FromAPI (clusterCopy , atlasCluster )
318318 if err != nil {
319319 return fmt .Errorf ("failed to translate Cluster from Atlas: %w" , err )
320320 }
321321
322- deps , err := h .getDependencies (ctx , cluster )
323- if err != nil {
324- return fmt .Errorf ("failed to resolve Cluster dependencies: %w" , err )
325- }
326-
327322 return ctrlstate .NewPatcher (cluster ).
328323 UpdateStateTracker (deps ... ).
329324 UpdateStatus ().
330325 Patch (ctx , h .kubeClient )
331326}
332327
333- func (h * Handlerv20250312 ) handleAtlasClusterState (
334- ctx context.Context ,
335- cluster * akov2generated.Cluster ,
336- atlasCluster * v20250312sdk.ClusterDescription20240805 ,
337- currentState , nextState state.ResourceState ,
338- ) (ctrlstate.Result , error ) {
339- err := h .patchStatus (ctx , cluster , atlasCluster )
328+ func (h * Handlerv20250312 ) handleAtlasClusterState (ctx context.Context , cluster * akov2generated.Cluster , atlasCluster * v20250312sdk.ClusterDescription20240805 , currentState , nextState state.ResourceState , deps ... client.Object ) (ctrlstate.Result , error ) {
329+ err := h .patchStatus (ctx , cluster , atlasCluster , deps ... )
340330 if err != nil {
341331 return result .Error (currentState , err )
342332 }
0 commit comments