@@ -95,7 +95,7 @@ func (o *objectMover) Move(namespace string, toCluster Client, dryRun bool, muta
95
95
proxy = toCluster .Proxy ()
96
96
}
97
97
98
- return o .move (objectGraph , proxy , mutators )
98
+ return o .move (objectGraph , proxy , mutators ... )
99
99
}
100
100
101
101
func (o * objectMover ) ToDirectory (namespace string , directory string ) error {
@@ -312,7 +312,7 @@ func getMachineObj(proxy Proxy, machine *node, machineObj *clusterv1.Machine) er
312
312
}
313
313
314
314
// Move moves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target management cluster.
315
- func (o * objectMover ) move (graph * objectGraph , toProxy Proxy , mutators [] ResourceMutatorFunc ) error {
315
+ func (o * objectMover ) move (graph * objectGraph , toProxy Proxy , mutators ... ResourceMutatorFunc ) error {
316
316
log := logf .Log
317
317
318
318
clusters := graph .getClusters ()
@@ -323,12 +323,12 @@ func (o *objectMover) move(graph *objectGraph, toProxy Proxy, mutators []Resourc
323
323
324
324
// Sets the pause field on the Cluster object in the source management cluster, so the controllers stop reconciling it.
325
325
log .V (1 ).Info ("Pausing the source cluster" )
326
- if err := setClusterPause (o .fromProxy , clusters , nil , true , o .dryRun ); err != nil {
326
+ if err := setClusterPause (o .fromProxy , clusters , true , o .dryRun ); err != nil {
327
327
return err
328
328
}
329
329
330
330
log .V (1 ).Info ("Pausing the source ClusterClasses" )
331
- if err := setClusterClassPause (o .fromProxy , clusterClasses , nil , true , o .dryRun ); err != nil {
331
+ if err := setClusterClassPause (o .fromProxy , clusterClasses , true , o .dryRun ); err != nil {
332
332
return errors .Wrap (err , "error pausing ClusterClasses" )
333
333
}
334
334
@@ -348,7 +348,7 @@ func (o *objectMover) move(graph *objectGraph, toProxy Proxy, mutators []Resourc
348
348
// Create all objects group by group, ensuring all the ownerReferences are re-created.
349
349
log .Info ("Creating objects in the target cluster" )
350
350
for groupIndex := 0 ; groupIndex < len (moveSequence .groups ); groupIndex ++ {
351
- if err := o .createGroup (moveSequence .getGroup (groupIndex ), toProxy , mutators ); err != nil {
351
+ if err := o .createGroup (moveSequence .getGroup (groupIndex ), toProxy , mutators ... ); err != nil {
352
352
return err
353
353
}
354
354
}
@@ -363,13 +363,13 @@ func (o *objectMover) move(graph *objectGraph, toProxy Proxy, mutators []Resourc
363
363
364
364
// Resume the ClusterClasses in the target management cluster, so the controllers start reconciling it.
365
365
log .V (1 ).Info ("Resuming the target ClusterClasses" )
366
- if err := setClusterClassPause (toProxy , clusterClasses , mutators , false , o .dryRun ); err != nil {
366
+ if err := setClusterClassPause (toProxy , clusterClasses , false , o .dryRun , mutators ... ); err != nil {
367
367
return errors .Wrap (err , "error resuming ClusterClasses" )
368
368
}
369
369
370
370
// Reset the pause field on the Cluster object in the target management cluster, so the controllers start reconciling it.
371
371
log .V (1 ).Info ("Resuming the target cluster" )
372
- return setClusterPause (toProxy , clusters , mutators , false , o .dryRun )
372
+ return setClusterPause (toProxy , clusters , false , o .dryRun , mutators ... )
373
373
}
374
374
375
375
func (o * objectMover ) toDirectory (graph * objectGraph , directory string ) error {
@@ -383,12 +383,12 @@ func (o *objectMover) toDirectory(graph *objectGraph, directory string) error {
383
383
384
384
// Sets the pause field on the Cluster object in the source management cluster, so the controllers stop reconciling it.
385
385
log .V (1 ).Info ("Pausing the source cluster" )
386
- if err := setClusterPause (o .fromProxy , clusters , nil , true , o .dryRun ); err != nil {
386
+ if err := setClusterPause (o .fromProxy , clusters , true , o .dryRun ); err != nil {
387
387
return err
388
388
}
389
389
390
390
log .V (1 ).Info ("Pausing the source ClusterClasses" )
391
- if err := setClusterClassPause (o .fromProxy , clusterClasses , nil , true , o .dryRun ); err != nil {
391
+ if err := setClusterClassPause (o .fromProxy , clusterClasses , true , o .dryRun ); err != nil {
392
392
return errors .Wrap (err , "error pausing ClusterClasses" )
393
393
}
394
394
@@ -409,13 +409,13 @@ func (o *objectMover) toDirectory(graph *objectGraph, directory string) error {
409
409
410
410
// Resume the ClusterClasses in the target management cluster, so the controllers start reconciling it.
411
411
log .V (1 ).Info ("Resuming the target ClusterClasses" )
412
- if err := setClusterClassPause (o .fromProxy , clusterClasses , nil , false , o .dryRun ); err != nil {
412
+ if err := setClusterClassPause (o .fromProxy , clusterClasses , false , o .dryRun ); err != nil {
413
413
return errors .Wrap (err , "error resuming ClusterClasses" )
414
414
}
415
415
416
416
// Reset the pause field on the Cluster object in the target management cluster, so the controllers start reconciling it.
417
417
log .V (1 ).Info ("Resuming the source cluster" )
418
- return setClusterPause (o .fromProxy , clusters , nil , false , o .dryRun )
418
+ return setClusterPause (o .fromProxy , clusters , false , o .dryRun )
419
419
}
420
420
421
421
func (o * objectMover ) fromDirectory (graph * objectGraph , toProxy Proxy ) error {
@@ -450,14 +450,14 @@ func (o *objectMover) fromDirectory(graph *objectGraph, toProxy Proxy) error {
450
450
// Resume reconciling the ClusterClasses after being restored from a backup.
451
451
// By default, during backup, ClusterClasses are paused so they must be unpaused to be used again
452
452
log .V (1 ).Info ("Resuming the target ClusterClasses" )
453
- if err := setClusterClassPause (toProxy , clusterClasses , nil , false , o .dryRun ); err != nil {
453
+ if err := setClusterClassPause (toProxy , clusterClasses , false , o .dryRun ); err != nil {
454
454
return errors .Wrap (err , "error resuming ClusterClasses" )
455
455
}
456
456
457
457
// Resume reconciling the Clusters after being restored from a directory.
458
458
// By default, when moved to a directory, Clusters are paused, so they must be unpaused to be used again.
459
459
log .V (1 ).Info ("Resuming the target cluster" )
460
- return setClusterPause (toProxy , clusters , nil , false , o .dryRun )
460
+ return setClusterPause (toProxy , clusters , false , o .dryRun )
461
461
}
462
462
463
463
// moveSequence defines a list of group of moveGroups.
@@ -536,7 +536,7 @@ func getMoveSequence(graph *objectGraph) *moveSequence {
536
536
}
537
537
538
538
// setClusterPause sets the paused field on nodes referring to Cluster objects.
539
- func setClusterPause (proxy Proxy , clusters []* node , mutators [] ResourceMutatorFunc , value bool , dryRun bool ) error {
539
+ func setClusterPause (proxy Proxy , clusters []* node , value bool , dryRun bool , mutators ... ResourceMutatorFunc ) error {
540
540
if dryRun {
541
541
return nil
542
542
}
@@ -557,7 +557,7 @@ func setClusterPause(proxy Proxy, clusters []*node, mutators []ResourceMutatorFu
557
557
558
558
// Nb. The operation is wrapped in a retry loop to make setClusterPause more resilient to unexpected conditions.
559
559
if err := retryWithExponentialBackoff (setClusterPauseBackoff , func () error {
560
- return patchCluster (proxy , cluster , patch , mutators )
560
+ return patchCluster (proxy , cluster , patch , mutators ... )
561
561
}); err != nil {
562
562
return errors .Wrapf (err , "error setting Cluster.Spec.Paused=%t" , value )
563
563
}
@@ -566,7 +566,7 @@ func setClusterPause(proxy Proxy, clusters []*node, mutators []ResourceMutatorFu
566
566
}
567
567
568
568
// setClusterClassPause sets the paused annotation on nodes referring to ClusterClass objects.
569
- func setClusterClassPause (proxy Proxy , clusterclasses []* node , mutators [] ResourceMutatorFunc , pause bool , dryRun bool ) error {
569
+ func setClusterClassPause (proxy Proxy , clusterclasses []* node , pause bool , dryRun bool , mutators ... ResourceMutatorFunc ) error {
570
570
if dryRun {
571
571
return nil
572
572
}
@@ -584,7 +584,7 @@ func setClusterClassPause(proxy Proxy, clusterclasses []*node, mutators []Resour
584
584
585
585
// Nb. The operation is wrapped in a retry loop to make setClusterClassPause more resilient to unexpected conditions.
586
586
if err := retryWithExponentialBackoff (setClusterClassPauseBackoff , func () error {
587
- return pauseClusterClass (proxy , clusterclass , pause , mutators )
587
+ return pauseClusterClass (proxy , clusterclass , pause , mutators ... )
588
588
}); err != nil {
589
589
return errors .Wrapf (err , "error updating ClusterClass %s/%s" , clusterclass .identity .Namespace , clusterclass .identity .Name )
590
590
}
@@ -593,7 +593,7 @@ func setClusterClassPause(proxy Proxy, clusterclasses []*node, mutators []Resour
593
593
}
594
594
595
595
// patchCluster applies a patch to a node referring to a Cluster object.
596
- func patchCluster (proxy Proxy , n * node , patch client.Patch , mutators [] ResourceMutatorFunc ) error {
596
+ func patchCluster (proxy Proxy , n * node , patch client.Patch , mutators ... ResourceMutatorFunc ) error {
597
597
cFrom , err := proxy .NewClient ()
598
598
if err != nil {
599
599
return err
@@ -622,7 +622,7 @@ func patchCluster(proxy Proxy, n *node, patch client.Patch, mutators []ResourceM
622
622
return nil
623
623
}
624
624
625
- func pauseClusterClass (proxy Proxy , n * node , pause bool , mutators [] ResourceMutatorFunc ) error {
625
+ func pauseClusterClass (proxy Proxy , n * node , pause bool , mutators ... ResourceMutatorFunc ) error {
626
626
cFrom , err := proxy .NewClient ()
627
627
if err != nil {
628
628
return errors .Wrap (err , "error creating client" )
@@ -768,7 +768,7 @@ func (o *objectMover) ensureNamespace(toProxy Proxy, namespace string) error {
768
768
}
769
769
770
770
// createGroup creates all the Kubernetes objects into the target management cluster corresponding to the object graph nodes in a moveGroup.
771
- func (o * objectMover ) createGroup (group moveGroup , toProxy Proxy , mutators [] ResourceMutatorFunc ) error {
771
+ func (o * objectMover ) createGroup (group moveGroup , toProxy Proxy , mutators ... ResourceMutatorFunc ) error {
772
772
createTargetObjectBackoff := newWriteBackoff ()
773
773
errList := []error {}
774
774
0 commit comments