Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Remove clusterctl restore command and Restore function from Client interface #7945

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions cmd/clusterctl/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ type Client interface {
// Move moves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target management cluster.
Move(options MoveOptions) error

// Restore restores all the Cluster API objects existing in a configured directory based on a glob to a target management cluster.
//
// Deprecated: This will be dropped in a future release. Please use Move.
Restore(options RestoreOptions) error

// PlanUpgrade returns a set of suggested Upgrade plans for the cluster, and more specifically:
// - Upgrade to the latest version in the v1alpha3 series: ....
// - Upgrade to the latest version in the v1alpha4 series: ....
Expand Down
4 changes: 0 additions & 4 deletions cmd/clusterctl/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ func (f fakeClient) Move(options MoveOptions) error {
return f.internalClient.Move(options)
}

func (f fakeClient) Restore(options RestoreOptions) error {
return f.internalClient.Restore(options)
}

func (f fakeClient) PlanUpgrade(options PlanUpgradeOptions) ([]UpgradePlan, error) {
return f.internalClient.PlanUpgrade(options)
}
Expand Down
11 changes: 0 additions & 11 deletions cmd/clusterctl/client/cluster/mover.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ type ObjectMover interface {

// FromDirectory reads all the Cluster API objects existing in a configured directory to a target management cluster.
FromDirectory(toCluster Client, directory string) error

// Restore restores all the Cluster API objects existing in a configured directory to a target management cluster.
//
// Deprecated: This will be dropped in a future release. Please use FromDirectory.
Restore(toCluster Client, directory string) error
}

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

func (o *objectMover) Restore(toCluster Client, directory string) error {
log := logf.Log
log.V(5).Info("Deprecated: This function will be dropped in a future release. Please use FromDirectory instead of Restore.")
return o.FromDirectory(toCluster, directory)
}

func (o *objectMover) FromDirectory(toCluster Client, directory string) error {
log := logf.Log
log.Info("Moving from directory...")
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/mover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ func Test_objectMover_filesToObjs(t *testing.T) {
}
}

func Test_objectMover_restore(t *testing.T) {
func Test_objectMover_fromDirectory(t *testing.T) {
// 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
for _, tt := range backupRestoreTests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
22 changes: 0 additions & 22 deletions cmd/clusterctl/client/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@ type MoveOptions struct {
DryRun bool
}

// RestoreOptions holds options supported by restore.
//
// Deprecated: This will be dropped in a future release. Please use MoveOptions.
type RestoreOptions struct {
// FromKubeconfig defines the kubeconfig to use for accessing the target management cluster. If empty,
// default rules for kubeconfig discovery will be used.
ToKubeconfig Kubeconfig

// Directory defines the local directory to restore cluster objects from
Directory string
}

func (c *clusterctlClient) Move(options MoveOptions) error {
// Both backup and restore makes no sense. It's a complete move.
if options.FromDirectory != "" && options.ToDirectory != "" {
Expand Down Expand Up @@ -144,16 +132,6 @@ func (c *clusterctlClient) toDirectory(options MoveOptions) error {
return fromCluster.ObjectMover().ToDirectory(options.Namespace, options.ToDirectory)
}

// Restore restores all the Cluster API objects existing in a configured directory to a target management cluster.
//
// Deprecated: This will be dropped in a future release. Please use FromDirectory.
func (c *clusterctlClient) Restore(options RestoreOptions) error {
return c.Move(MoveOptions{
ToKubeconfig: options.ToKubeconfig,
FromDirectory: options.Directory,
})
}

func (c *clusterctlClient) getClusterClient(kubeconfig Kubeconfig) (cluster.Client, error) {
cluster, err := c.clusterClientFactory(ClusterClientFactoryInput{Kubeconfig: kubeconfig})
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions cmd/clusterctl/client/move_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func Test_clusterctlClient_ToDirectory(t *testing.T) {
}
}

func Test_clusterctlClient_Restore(t *testing.T) {
func Test_clusterctlClient_FromDirectory(t *testing.T) {
dir, err := os.MkdirTemp("/tmp", "cluster-api")
if err != nil {
t.Error(err)
Expand All @@ -215,7 +215,7 @@ func Test_clusterctlClient_Restore(t *testing.T) {
// These tests are checking the Restore scaffolding
// The internal library handles the restore logic and tests can be found there
type args struct {
options RestoreOptions
options MoveOptions
}
tests := []struct {
name string
Expand All @@ -229,9 +229,9 @@ func Test_clusterctlClient_Restore(t *testing.T) {
client: fakeClientForMove(), // core v1.0.0 (v1.0.1 available), infra v2.0.0 (v2.0.1 available)
},
args: args{
options: RestoreOptions{
ToKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "mgmt-context"},
Directory: dir,
options: MoveOptions{
ToKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "mgmt-context"},
FromDirectory: dir,
},
},
wantErr: false,
Expand All @@ -242,9 +242,9 @@ func Test_clusterctlClient_Restore(t *testing.T) {
client: fakeClientForMove(), // core v1.0.0 (v1.0.1 available), infra v2.0.0 (v2.0.1 available)
},
args: args{
options: RestoreOptions{
ToKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "does-not-exist"},
Directory: dir,
options: MoveOptions{
ToKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "does-not-exist"},
FromDirectory: dir,
},
},
wantErr: true,
Expand All @@ -255,7 +255,7 @@ func Test_clusterctlClient_Restore(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)

err := tt.fields.client.Restore(tt.args.options)
err := tt.fields.client.Move(tt.args.options)
if tt.wantErr {
g.Expect(err).To(HaveOccurred())
return
Expand Down
76 changes: 0 additions & 76 deletions cmd/clusterctl/cmd/restore.go

This file was deleted.

7 changes: 0 additions & 7 deletions docs/book/src/clusterctl/commands/additional-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ $HOME/.cluster-api/clusterctl.yaml file to add a new provider or to customize ex
Help provides help for any command in the application.
Simply type `clusterctl help [command]` for full details.

# clusterctl restore

**DEPRECATED. Please use `clusterctl move --from-directory` instead.**

Restore Cluster API objects from file by glob. Object files are searched in the default config directory
or in the provided directory.

# clusterctl version

Print clusterctl version.
Expand Down
1 change: 0 additions & 1 deletion docs/book/src/clusterctl/commands/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
| [`clusterctl init`](init.md) | Initialize a management cluster. |
| [`clusterctl init list-images`](additional-commands.md#clusterctl-init-list-images) | Lists the container images required for initializing the management cluster. |
| [`clusterctl move`](move.md) | Move Cluster API objects and all their dependencies between management clusters. |
| [`clusterctl restore`](additional-commands.md#clusterctl-restore) | Restore Cluster API objects from file by glob. **DEPRECATED. Please use `clusterctl move --from-directory` instead.** |
| [`clusterctl upgrade plan`](upgrade.md#upgrade-plan) | Provide a list of recommended target versions for upgrading Cluster API providers in a management cluster. |
| [`clusterctl upgrade apply`](upgrade.md#upgrade-apply) | Apply new versions of Cluster API core and providers in a management cluster. |
| [`clusterctl version`](additional-commands.md#clusterctl-version) | Print clusterctl version. |
2 changes: 2 additions & 0 deletions docs/book/src/developer/providers/v1.3-to-v1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ maintainers of providers and consumers of our Go API.
### Removals

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

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

### Other

Expand Down