@@ -45,9 +45,19 @@ import (
4545type ObjectMover interface {
4646 // Move moves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target management cluster.
4747 Move (namespace string , toCluster Client , dryRun bool ) error
48- // Backup saves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target management cluster.
48+
49+ // ToDirectory writes all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target directory.
50+ ToDirectory (namespace string , directory string ) error
51+
52+ // FromDirectory reads all the Cluster API objects existing in a configured directory to a target management cluster.
53+ FromDirectory (toCluster Client , directory string ) error
54+
55+ // Backup saves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target directory.
56+ // Deprecated: This will be dropped in a future release. Please use ToDirectory.
4957 Backup (namespace string , directory string ) error
58+
5059 // Restore restores all the Cluster API objects existing in a configured directory to a target management cluster.
60+ // Deprecated: This will be dropped in a future release. Please use FromDirectory.
5161 Restore (toCluster Client , directory string ) error
5262}
5363
@@ -94,21 +104,33 @@ func (o *objectMover) Move(namespace string, toCluster Client, dryRun bool) erro
94104
95105func (o * objectMover ) Backup (namespace string , directory string ) error {
96106 log := logf .Log
97- log .Info ("Performing backup..." )
107+ log .V (5 ).Info ("Deprecated: This function will be dropped in a future release. Please use ToDirectory instead of Backup." )
108+ return o .ToDirectory (namespace , directory )
109+ }
110+
111+ func (o * objectMover ) ToDirectory (namespace string , directory string ) error {
112+ log := logf .Log
113+ log .Info ("Moving to directory..." )
98114
99115 objectGraph , err := o .getObjectGraph (namespace )
100116 if err != nil {
101117 return errors .Wrap (err , "failed to get object graph" )
102118 }
103119
104- return o .backup (objectGraph , directory )
120+ return o .toDirectory (objectGraph , directory )
105121}
106122
107123func (o * objectMover ) Restore (toCluster Client , directory string ) error {
108124 log := logf .Log
109- log .Info ("Performing restore..." )
125+ log .V (5 ).Info ("Deprecated: This function will be dropped in a future release. Please use FromDirectory instead of Restore." )
126+ return o .FromDirectory (toCluster , directory )
127+ }
128+
129+ func (o * objectMover ) FromDirectory (toCluster Client , directory string ) error {
130+ log := logf .Log
131+ log .Info ("Moving from directory..." )
110132
111- // Build an empty object graph used for the restore sequence not tied to a specific namespace
133+ // Build an empty object graph used for the fromDirectory sequence not tied to a specific namespace
112134 objectGraph := newObjectGraph (o .fromProxy , o .fromProviderInventory )
113135
114136 // Gets all the types defined by the CRDs installed by clusterctl plus the ConfigMap/Secret core types.
@@ -135,13 +157,13 @@ func (o *objectMover) Restore(toCluster Client, directory string) error {
135157 // Completes the graph by setting for each node the list of tenants the node belongs to.
136158 objectGraph .setTenants ()
137159
138- // Check whether nodes are not included in GVK considered for restore .
160+ // Check whether nodes are not included in GVK considered for fromDirectory .
139161 objectGraph .checkVirtualNode ()
140162
141163 // Restore the objects to the target cluster.
142164 proxy := toCluster .Proxy ()
143165
144- return o .restore (objectGraph , proxy )
166+ return o .fromDirectory (objectGraph , proxy )
145167}
146168
147169func (o * objectMover ) filesToObjs (dir string ) ([]unstructured.Unstructured , error ) {
@@ -191,7 +213,7 @@ func (o *objectMover) getObjectGraph(namespace string) (*objectGraph, error) {
191213 return nil , errors .Wrap (err , "failed to discover the object graph" )
192214 }
193215
194- // Checks if Cluster API has already completed the provisioning of the infrastructure for the objects involved in the move/backup operation.
216+ // Checks if Cluster API has already completed the provisioning of the infrastructure for the objects involved in the move/toDirectory operation.
195217 // This is required because if the infrastructure is provisioned, then we can reasonably assume that the objects we are moving/backing up are
196218 // not currently waiting for long-running reconciliation loops, and so we can safely rely on the pause field on the Cluster object
197219 // for blocking any further object reconciliation on the source objects.
@@ -366,11 +388,11 @@ func (o *objectMover) move(graph *objectGraph, toProxy Proxy) error {
366388 return setClusterPause (toProxy , clusters , false , o .dryRun )
367389}
368390
369- func (o * objectMover ) backup (graph * objectGraph , directory string ) error {
391+ func (o * objectMover ) toDirectory (graph * objectGraph , directory string ) error {
370392 log := logf .Log
371393
372394 clusters := graph .getClusters ()
373- log .Info ("Starting backup of Cluster API objects" , "Clusters" , len (clusters ))
395+ log .Info ("Starting move of Cluster API objects" , "Clusters" , len (clusters ))
374396
375397 clusterClasses := graph .getClusterClasses ()
376398 log .Info ("Moving Cluster API objects" , "ClusterClasses" , len (clusterClasses ))
@@ -412,7 +434,7 @@ func (o *objectMover) backup(graph *objectGraph, directory string) error {
412434 return setClusterPause (o .fromProxy , clusters , false , o .dryRun )
413435}
414436
415- func (o * objectMover ) restore (graph * objectGraph , toProxy Proxy ) error {
437+ func (o * objectMover ) fromDirectory (graph * objectGraph , toProxy Proxy ) error {
416438 log := logf .Log
417439
418440 // Get clusters from graph
@@ -448,8 +470,8 @@ func (o *objectMover) restore(graph *objectGraph, toProxy Proxy) error {
448470 return errors .Wrap (err , "error resuming ClusterClasses" )
449471 }
450472
451- // Resume reconciling the Clusters after being restored from a backup .
452- // By default, during backup , Clusters are paused so they must be unpaused to be used again
473+ // Resume reconciling the Clusters after being restored from a directory .
474+ // By default, when moved to a directory , Clusters are paused, so they must be unpaused to be used again.
453475 log .V (1 ).Info ("Resuming the target cluster" )
454476 return setClusterPause (toProxy , clusters , false , o .dryRun )
455477}
@@ -972,7 +994,7 @@ func (o *objectMover) restoreTargetObject(nodeToCreate *node, toProxy Proxy) err
972994 existingTargetObj .SetAPIVersion (nodeToCreate .restoreObject .GetAPIVersion ())
973995 existingTargetObj .SetKind (nodeToCreate .restoreObject .GetKind ())
974996 if err := cTo .Get (ctx , objKey , existingTargetObj ); err == nil {
975- log .V (5 ).Info ("Object already exists, skipping restore " , nodeToCreate .identity .Kind , nodeToCreate .identity .Name , "Namespace" , nodeToCreate .identity .Namespace )
997+ log .V (5 ).Info ("Object already exists, skipping moving from directory " , nodeToCreate .identity .Kind , nodeToCreate .identity .Name , "Namespace" , nodeToCreate .identity .Namespace )
976998
977999 // Update the nodes UID since it already exits. Any nodes owned by this existing node will be updated when the owner chain is rebuilt
9781000 nodeToCreate .newUID = existingTargetObj .GetUID ()
0 commit comments