Skip to content

Commit 9dfb8bb

Browse files
authored
Merge pull request kubernetes-sigs#7945 from hackeramitkumar/main
⚠️ Remove clusterctl restore command and Restore function from Client interface
2 parents 725addb + c1d8504 commit 9dfb8bb

File tree

10 files changed

+12
-136
lines changed

10 files changed

+12
-136
lines changed

cmd/clusterctl/client/client.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ type Client interface {
5454
// Move moves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target management cluster.
5555
Move(options MoveOptions) error
5656

57-
// Restore restores all the Cluster API objects existing in a configured directory based on a glob to a target management cluster.
58-
//
59-
// Deprecated: This will be dropped in a future release. Please use Move.
60-
Restore(options RestoreOptions) error
61-
6257
// PlanUpgrade returns a set of suggested Upgrade plans for the cluster, and more specifically:
6358
// - Upgrade to the latest version in the v1alpha3 series: ....
6459
// - Upgrade to the latest version in the v1alpha4 series: ....

cmd/clusterctl/client/client_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ func (f fakeClient) Move(options MoveOptions) error {
108108
return f.internalClient.Move(options)
109109
}
110110

111-
func (f fakeClient) Restore(options RestoreOptions) error {
112-
return f.internalClient.Restore(options)
113-
}
114-
115111
func (f fakeClient) PlanUpgrade(options PlanUpgradeOptions) ([]UpgradePlan, error) {
116112
return f.internalClient.PlanUpgrade(options)
117113
}

cmd/clusterctl/client/cluster/mover.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ type ObjectMover interface {
5252

5353
// FromDirectory reads all the Cluster API objects existing in a configured directory to a target management cluster.
5454
FromDirectory(toCluster Client, directory string) error
55-
56-
// Restore restores all the Cluster API objects existing in a configured directory to a target management cluster.
57-
//
58-
// Deprecated: This will be dropped in a future release. Please use FromDirectory.
59-
Restore(toCluster Client, directory string) error
6055
}
6156

6257
// objectMover implements the ObjectMover interface.
@@ -112,12 +107,6 @@ func (o *objectMover) ToDirectory(namespace string, directory string) error {
112107
return o.toDirectory(objectGraph, directory)
113108
}
114109

115-
func (o *objectMover) Restore(toCluster Client, directory string) error {
116-
log := logf.Log
117-
log.V(5).Info("Deprecated: This function will be dropped in a future release. Please use FromDirectory instead of Restore.")
118-
return o.FromDirectory(toCluster, directory)
119-
}
120-
121110
func (o *objectMover) FromDirectory(toCluster Client, directory string) error {
122111
log := logf.Log
123112
log.Info("Moving from directory...")

cmd/clusterctl/client/cluster/mover_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ func Test_objectMover_filesToObjs(t *testing.T) {
974974
}
975975
}
976976

977-
func Test_objectMover_restore(t *testing.T) {
977+
func Test_objectMover_fromDirectory(t *testing.T) {
978978
// NB. we are testing the move and move sequence using the same set of moveTests, but checking the results at different stages of the move process
979979
for _, tt := range backupRestoreTests {
980980
t.Run(tt.name, func(t *testing.T) {

cmd/clusterctl/client/move.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@ type MoveOptions struct {
4848
DryRun bool
4949
}
5050

51-
// RestoreOptions holds options supported by restore.
52-
//
53-
// Deprecated: This will be dropped in a future release. Please use MoveOptions.
54-
type RestoreOptions struct {
55-
// FromKubeconfig defines the kubeconfig to use for accessing the target management cluster. If empty,
56-
// default rules for kubeconfig discovery will be used.
57-
ToKubeconfig Kubeconfig
58-
59-
// Directory defines the local directory to restore cluster objects from
60-
Directory string
61-
}
62-
6351
func (c *clusterctlClient) Move(options MoveOptions) error {
6452
// Both backup and restore makes no sense. It's a complete move.
6553
if options.FromDirectory != "" && options.ToDirectory != "" {
@@ -144,16 +132,6 @@ func (c *clusterctlClient) toDirectory(options MoveOptions) error {
144132
return fromCluster.ObjectMover().ToDirectory(options.Namespace, options.ToDirectory)
145133
}
146134

147-
// Restore restores all the Cluster API objects existing in a configured directory to a target management cluster.
148-
//
149-
// Deprecated: This will be dropped in a future release. Please use FromDirectory.
150-
func (c *clusterctlClient) Restore(options RestoreOptions) error {
151-
return c.Move(MoveOptions{
152-
ToKubeconfig: options.ToKubeconfig,
153-
FromDirectory: options.Directory,
154-
})
155-
}
156-
157135
func (c *clusterctlClient) getClusterClient(kubeconfig Kubeconfig) (cluster.Client, error) {
158136
cluster, err := c.clusterClientFactory(ClusterClientFactoryInput{Kubeconfig: kubeconfig})
159137
if err != nil {

cmd/clusterctl/client/move_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func Test_clusterctlClient_ToDirectory(t *testing.T) {
202202
}
203203
}
204204

205-
func Test_clusterctlClient_Restore(t *testing.T) {
205+
func Test_clusterctlClient_FromDirectory(t *testing.T) {
206206
dir, err := os.MkdirTemp("/tmp", "cluster-api")
207207
if err != nil {
208208
t.Error(err)
@@ -215,7 +215,7 @@ func Test_clusterctlClient_Restore(t *testing.T) {
215215
// These tests are checking the Restore scaffolding
216216
// The internal library handles the restore logic and tests can be found there
217217
type args struct {
218-
options RestoreOptions
218+
options MoveOptions
219219
}
220220
tests := []struct {
221221
name string
@@ -229,9 +229,9 @@ func Test_clusterctlClient_Restore(t *testing.T) {
229229
client: fakeClientForMove(), // core v1.0.0 (v1.0.1 available), infra v2.0.0 (v2.0.1 available)
230230
},
231231
args: args{
232-
options: RestoreOptions{
233-
ToKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "mgmt-context"},
234-
Directory: dir,
232+
options: MoveOptions{
233+
ToKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "mgmt-context"},
234+
FromDirectory: dir,
235235
},
236236
},
237237
wantErr: false,
@@ -242,9 +242,9 @@ func Test_clusterctlClient_Restore(t *testing.T) {
242242
client: fakeClientForMove(), // core v1.0.0 (v1.0.1 available), infra v2.0.0 (v2.0.1 available)
243243
},
244244
args: args{
245-
options: RestoreOptions{
246-
ToKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "does-not-exist"},
247-
Directory: dir,
245+
options: MoveOptions{
246+
ToKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "does-not-exist"},
247+
FromDirectory: dir,
248248
},
249249
},
250250
wantErr: true,
@@ -255,7 +255,7 @@ func Test_clusterctlClient_Restore(t *testing.T) {
255255
t.Run(tt.name, func(t *testing.T) {
256256
g := NewWithT(t)
257257

258-
err := tt.fields.client.Restore(tt.args.options)
258+
err := tt.fields.client.Move(tt.args.options)
259259
if tt.wantErr {
260260
g.Expect(err).To(HaveOccurred())
261261
return

cmd/clusterctl/cmd/restore.go

Lines changed: 0 additions & 76 deletions
This file was deleted.

docs/book/src/clusterctl/commands/additional-commands.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ $HOME/.cluster-api/clusterctl.yaml file to add a new provider or to customize ex
1010
Help provides help for any command in the application.
1111
Simply type `clusterctl help [command]` for full details.
1212

13-
# clusterctl restore
14-
15-
**DEPRECATED. Please use `clusterctl move --from-directory` instead.**
16-
17-
Restore Cluster API objects from file by glob. Object files are searched in the default config directory
18-
or in the provided directory.
19-
2013
# clusterctl version
2114

2215
Print clusterctl version.

docs/book/src/clusterctl/commands/commands.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
| [`clusterctl init`](init.md) | Initialize a management cluster. |
1717
| [`clusterctl init list-images`](additional-commands.md#clusterctl-init-list-images) | Lists the container images required for initializing the management cluster. |
1818
| [`clusterctl move`](move.md) | Move Cluster API objects and all their dependencies between management clusters. |
19-
| [`clusterctl restore`](additional-commands.md#clusterctl-restore) | Restore Cluster API objects from file by glob. **DEPRECATED. Please use `clusterctl move --from-directory` instead.** |
2019
| [`clusterctl upgrade plan`](upgrade.md#upgrade-plan) | Provide a list of recommended target versions for upgrading Cluster API providers in a management cluster. |
2120
| [`clusterctl upgrade apply`](upgrade.md#upgrade-apply) | Apply new versions of Cluster API core and providers in a management cluster. |
2221
| [`clusterctl version`](additional-commands.md#clusterctl-version) | Print clusterctl version. |

docs/book/src/developer/providers/v1.3-to-v1.4.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ maintainers of providers and consumers of our Go API.
2323
### Removals
2424

2525
- `clusterctl backup` has been removed.
26+
- `clusterctl restore` has been removed.
2627
- `api/v1beta1.MachineHealthCheckSuccededCondition` condition type has been removed.
2728
- `controller/external/util.CloneTemplate` and `controllers/external/util.CloneTemplateInput` has been removed.
2829
- The option `--list-images` from `clusterctl init` subcommand has been removed.
@@ -33,6 +34,7 @@ maintainers of providers and consumers of our Go API.
3334
### API Changes
3435

3536
- `Backup(options BackupOptions) error` in the Client interface has been removed.
37+
- `Restore(options RestoreOptions) error` in the Client interface has been removed.
3638

3739
### Other
3840

0 commit comments

Comments
 (0)