@@ -289,11 +289,22 @@ func (r *reconcilerImpl) ReconcileDelete(ctx context.Context, request reconcile.
289289 return reconcile.Result {}, nil
290290}
291291
292+ // Manager is an interface for managing cluster access.
292293type Manager interface {
294+ // WithTimeout sets the timeout for operations.
293295 WithTimeout (timeout time.Duration ) Manager
296+ // WithInterval sets the interval for polling operations.
294297 WithInterval (interval time.Duration ) Manager
298+ // WithLogger sets the logger for the manager.
295299 WithLogger (log * logging.Logger ) Manager
296300
301+ // CreateAndWaitForCluster creates a new ClusterRequest/AccessRequest and waits for it to be ready.
302+ // It returns the created Cluster if the AccessRequest is granted.
303+ // ctx is the context for the operation.
304+ // clusterName is the name of the cluster to create.
305+ // purpose is the purpose of the cluster (e.g., "onboarding", "mcp", "workload").
306+ // scheme is the runtime scheme to use for the cluster.
307+ // permissions are the permissions to request for the AccessRequest.
297308 CreateAndWaitForCluster (ctx context.Context , clusterName , purpose string ,
298309 scheme * runtime.Scheme , permissions []clustersv1alpha1.PermissionsRequest ) (* clusters.Cluster , error )
299310}
@@ -335,11 +346,11 @@ func (m *managerImpl) WithLogger(log *logging.Logger) Manager {
335346func (m * managerImpl ) CreateAndWaitForCluster (ctx context.Context , clusterName , purpose string ,
336347 scheme * runtime.Scheme , permissions []clustersv1alpha1.PermissionsRequest ) (* clusters.Cluster , error ) {
337348
338- namespace := libutils .StableRequestNamespace (m .controllerName )
349+ namespace := libutils .StableControllerNamespace (m .controllerName )
339350
340351 namespaceMutator := resources .NewNamespaceMutator (namespace )
341352 if err := resources .CreateOrUpdateResource (ctx , m .platformClusterClient , namespaceMutator ); err != nil {
342- return nil , fmt .Errorf ("failed to create/update provider namespace: %w" , err )
353+ return nil , fmt .Errorf ("failed to create/update namespace: %w" , err )
343354 }
344355
345356 cr := & clustersv1alpha1.ClusterRequest {
@@ -355,7 +366,7 @@ func (m *managerImpl) CreateAndWaitForCluster(ctx context.Context, clusterName,
355366 }))
356367
357368 if err := resources .CreateOrUpdateResource (ctx , m .platformClusterClient , clusterRequestMutator ); err != nil {
358- return nil , fmt .Errorf ("failed to create/update onboarding cluster request : %w" , err )
369+ return nil , fmt .Errorf ("failed to create/update ClusterRequest : %w" , err )
359370 }
360371
361372 err := m .wait (ctx , func (ctx context.Context ) (bool , error ) {
@@ -364,14 +375,14 @@ func (m *managerImpl) CreateAndWaitForCluster(ctx context.Context, clusterName,
364375 }
365376
366377 if m .log != nil {
367- m .log .Info ("Waiting for access request " , "name" , cr .Name , "phase" , cr .Status .Phase )
378+ m .log .Info ("Waiting for ClusterRequest " , "name" , cr .Name , "phase" , cr .Status .Phase )
368379 }
369380
370381 return cr .Status .Phase .IsGranted () || cr .Status .Phase .IsDenied (), nil
371382 })
372383
373384 if err != nil {
374- return nil , fmt .Errorf ("failed to wait for cluster request : %w" , err )
385+ return nil , fmt .Errorf ("failed to wait for ClusterRequest : %w" , err )
375386 }
376387
377388 ar := & clustersv1alpha1.AccessRequest {
@@ -394,7 +405,7 @@ func (m *managerImpl) CreateAndWaitForCluster(ctx context.Context, clusterName,
394405 }))
395406
396407 if err := resources .CreateOrUpdateResource (ctx , m .platformClusterClient , accessRequestMutator ); err != nil {
397- return nil , fmt .Errorf ("failed to create/update onboarding access request : %w" , err )
408+ return nil , fmt .Errorf ("failed to create/update AccessRequest : %w" , err )
398409 }
399410
400411 err = m .wait (ctx , func (ctx context.Context ) (bool , error ) {
@@ -403,14 +414,14 @@ func (m *managerImpl) CreateAndWaitForCluster(ctx context.Context, clusterName,
403414 }
404415
405416 if m .log != nil {
406- m .log .Info ("Waiting for access request " , "name" , ar .Name , "phase" , ar .Status .Phase )
417+ m .log .Info ("Waiting for AccessRequest " , "name" , ar .Name , "phase" , ar .Status .Phase )
407418 }
408419
409420 return ar .Status .Phase .IsGranted () || ar .Status .Phase .IsDenied (), nil
410421 })
411422
412423 if err != nil {
413- return nil , fmt .Errorf ("failed to wait for access request : %w" , err )
424+ return nil , fmt .Errorf ("failed to wait for AccessRequest : %w" , err )
414425 }
415426
416427 return createClusterForAccessRequest (ctx , m .platformClusterClient , clustersv1alpha1 .PURPOSE_ONBOARDING , scheme , ar )
0 commit comments