Skip to content

Commit

Permalink
Merge pull request #7752 from oscr/clusterctl-backup-remove
Browse files Browse the repository at this point in the history
🌱 Remove `clusterctl backup` command and Backup function from Client interface
  • Loading branch information
k8s-ci-robot authored Dec 29, 2022
2 parents 9b70157 + cbcf6d5 commit 9845887
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 145 deletions.
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

// Backup saves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target management cluster.
//
// Deprecated: This will be dropped in a future release. Please use Move.
Backup(options BackupOptions) 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.
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) Backup(options BackupOptions) error {
return f.internalClient.Backup(options)
}

func (f fakeClient) Restore(options RestoreOptions) error {
return f.internalClient.Restore(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 @@ -53,11 +53,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

// Backup saves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target directory.
//
// Deprecated: This will be dropped in a future release. Please use ToDirectory.
Backup(namespace string, 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.
Expand Down Expand Up @@ -105,12 +100,6 @@ func (o *objectMover) Move(namespace string, toCluster Client, dryRun bool) erro
return o.move(objectGraph, proxy)
}

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

func (o *objectMover) ToDirectory(namespace string, directory string) error {
log := logf.Log
log.Info("Moving to 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 @@ -840,7 +840,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
}
}

func Test_objectMover_backup(t *testing.T) {
func Test_objectMover_toDirectory(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
27 changes: 0 additions & 27 deletions cmd/clusterctl/client/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,6 @@ type MoveOptions struct {
DryRun bool
}

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

// Namespace where the objects describing the workload cluster exists. If unspecified, the current
// namespace will be used.
Namespace string

// Directory defines the local directory to store the cluster objects
Directory string
}

// RestoreOptions holds options supported by restore.
//
// Deprecated: This will be dropped in a future release. Please use MoveOptions.
Expand Down Expand Up @@ -160,17 +144,6 @@ func (c *clusterctlClient) toDirectory(options MoveOptions) error {
return fromCluster.ObjectMover().ToDirectory(options.Namespace, options.ToDirectory)
}

// Backup saves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target directory.
//
// Deprecated: This will be dropped in a future release. Please use ToDirectory.
func (c *clusterctlClient) Backup(options BackupOptions) error {
return c.Move(MoveOptions{
FromKubeconfig: options.FromKubeconfig,
ToDirectory: options.Directory,
Namespace: options.Namespace,
})
}

// 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.
Expand Down
14 changes: 7 additions & 7 deletions cmd/clusterctl/client/move_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func Test_clusterctlClient_Move(t *testing.T) {
}
}

func Test_clusterctlClient_Backup(t *testing.T) {
func Test_clusterctlClient_ToDirectory(t *testing.T) {
dir, err := os.MkdirTemp("/tmp", "cluster-api")
if err != nil {
t.Error(err)
Expand All @@ -152,7 +152,7 @@ func Test_clusterctlClient_Backup(t *testing.T) {
// These tests are checking the Backup scaffolding
// The internal library handles the backup logic and tests can be found there
type args struct {
options BackupOptions
options MoveOptions
}
tests := []struct {
name string
Expand All @@ -166,9 +166,9 @@ func Test_clusterctlClient_Backup(t *testing.T) {
client: fakeClientForMove(), // core v1.0.0 (v1.0.1 available), infra v2.0.0 (v2.0.1 available)
},
args: args{
options: BackupOptions{
options: MoveOptions{
FromKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "mgmt-context"},
Directory: dir,
ToDirectory: dir,
},
},
wantErr: false,
Expand All @@ -179,9 +179,9 @@ func Test_clusterctlClient_Backup(t *testing.T) {
client: fakeClientForMove(), // core v1.0.0 (v1.0.1 available), infra v2.0.0 (v2.0.1 available)
},
args: args{
options: BackupOptions{
options: MoveOptions{
FromKubeconfig: Kubeconfig{Path: "kubeconfig", Context: "does-not-exist"},
Directory: dir,
ToDirectory: dir,
},
},
wantErr: true,
Expand All @@ -192,7 +192,7 @@ func Test_clusterctlClient_Backup(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)

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

This file was deleted.

6 changes: 0 additions & 6 deletions docs/book/src/clusterctl/commands/additional-commands.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# clusterctl backup

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

Backup Cluster API objects and all dependencies from a management cluster.

# clusterctl config repositories

Display the list of providers and their repository configurations.
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 @@ -4,7 +4,6 @@
|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`clusterctl alpha rollout`](alpha-rollout.md) | Manages the rollout of Cluster API resources. For example: MachineDeployments. |
| [`clusterctl alpha topology plan`](alpha-topology-plan.md) | Describes the changes to a cluster topology for a given input. |
| [`clusterctl backup`](additional-commands.md#clusterctl-backup) | Backup Cluster API objects and all their dependencies from a management cluster. **DEPRECATED. Please use `clusterctl move --to-directory` instead.** |
| [`clusterctl completion`](completion.md) | Output shell completion code for the specified shell (bash or zsh). |
| [`clusterctl config`](additional-commands.md#clusterctl-config-repositories) | Display clusterctl configuration. |
| [`clusterctl delete`](delete.md) | Delete one or more providers from the management cluster. |
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/clusterctl/commands/move.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ while doing the move operation, and possible race conditions happening while the
remediating etc. has never been investigated nor addressed.

In order to avoid further confusion about this point, `clusterctl backup` and `clusterctl restore` commands have been
deprecated because they were built on top of `clusterctl move` logic and they were sharing he same limitations.
removed because they were built on top of `clusterctl move` logic and they were sharing he same limitations.
User can use `clusterctl move --to-directory` and `clusterctl move --from-directory` instead; this will hopefully
make it clear those operation have the same limitations of the move command.

Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/developer/providers/v1.3-to-v1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ maintainers of providers and consumers of our Go API.

### Removals

-
- `clusterctl backup` has been removed.

### API Changes

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

### Other

Expand Down

0 comments on commit 9845887

Please sign in to comment.