diff --git a/cmd/clusterctl/client/client.go b/cmd/clusterctl/client/client.go index 4b0eea5ed742..1aaf5b0e40ca 100644 --- a/cmd/clusterctl/client/client.go +++ b/cmd/clusterctl/client/client.go @@ -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. diff --git a/cmd/clusterctl/client/client_test.go b/cmd/clusterctl/client/client_test.go index 6da604f0e89c..ca24a33c069d 100644 --- a/cmd/clusterctl/client/client_test.go +++ b/cmd/clusterctl/client/client_test.go @@ -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) } diff --git a/cmd/clusterctl/client/cluster/mover.go b/cmd/clusterctl/client/cluster/mover.go index e587ae67dff1..61c23c045be2 100644 --- a/cmd/clusterctl/client/cluster/mover.go +++ b/cmd/clusterctl/client/cluster/mover.go @@ -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. @@ -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...") diff --git a/cmd/clusterctl/client/cluster/mover_test.go b/cmd/clusterctl/client/cluster/mover_test.go index 5882abd061c7..499d28e5268e 100644 --- a/cmd/clusterctl/client/cluster/mover_test.go +++ b/cmd/clusterctl/client/cluster/mover_test.go @@ -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) { diff --git a/cmd/clusterctl/client/move.go b/cmd/clusterctl/client/move.go index d5534cbc36c3..8f936af84500 100644 --- a/cmd/clusterctl/client/move.go +++ b/cmd/clusterctl/client/move.go @@ -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. @@ -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. diff --git a/cmd/clusterctl/client/move_test.go b/cmd/clusterctl/client/move_test.go index 3b9245cf2d4b..94808b12167c 100644 --- a/cmd/clusterctl/client/move_test.go +++ b/cmd/clusterctl/client/move_test.go @@ -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) @@ -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 @@ -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, @@ -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, @@ -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 diff --git a/cmd/clusterctl/cmd/backup.go b/cmd/clusterctl/cmd/backup.go deleted file mode 100644 index 9762480e2715..000000000000 --- a/cmd/clusterctl/cmd/backup.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "sigs.k8s.io/cluster-api/cmd/clusterctl/client" -) - -type backupOptions struct { - fromKubeconfig string - fromKubeconfigContext string - namespace string - directory string -} - -var buo = &backupOptions{} - -var backupCmd = &cobra.Command{ - Use: "backup", - GroupID: groupManagement, - Short: "Backup Cluster API objects and all dependencies from a management cluster", - Long: LongDesc(` - Backup Cluster API objects and all dependencies from a management cluster.`), - - Example: Examples(` - Backup Cluster API objects and all dependencies from a management cluster. - clusterctl backup --directory=/tmp/backup-directory`), - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return runBackup() - }, - Deprecated: "use 'clusterctl move --to-directory' instead.", -} - -func init() { - backupCmd.Flags().StringVar(&buo.fromKubeconfig, "kubeconfig", "", - "Path to the kubeconfig file for the source management cluster to backup. If unspecified, default discovery rules apply.") - backupCmd.Flags().StringVar(&buo.fromKubeconfigContext, "kubeconfig-context", "", - "Context to be used within the kubeconfig file for the source management cluster. If empty, current context will be used.") - backupCmd.Flags().StringVarP(&buo.namespace, "namespace", "n", "", - "The namespace where the workload cluster is hosted. If unspecified, the current context's namespace is used.") - backupCmd.Flags().StringVar(&buo.directory, "directory", "", - "The directory to save Cluster API objects to as yaml files") - - RootCmd.AddCommand(backupCmd) -} - -func runBackup() error { - if buo.directory == "" { - return errors.New("please specify a directory to backup cluster API objects to using the --directory flag") - } - - c, err := client.New(cfgFile) - if err != nil { - return err - } - - return c.Move(client.MoveOptions{ - FromKubeconfig: client.Kubeconfig{Path: buo.fromKubeconfig, Context: buo.fromKubeconfigContext}, - Namespace: buo.namespace, - ToDirectory: buo.directory, - }) -} diff --git a/docs/book/src/clusterctl/commands/additional-commands.md b/docs/book/src/clusterctl/commands/additional-commands.md index 6a947842edfb..dbd0e138c523 100644 --- a/docs/book/src/clusterctl/commands/additional-commands.md +++ b/docs/book/src/clusterctl/commands/additional-commands.md @@ -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. diff --git a/docs/book/src/clusterctl/commands/commands.md b/docs/book/src/clusterctl/commands/commands.md index 4c0e2fd544bb..52c68caf2bf1 100644 --- a/docs/book/src/clusterctl/commands/commands.md +++ b/docs/book/src/clusterctl/commands/commands.md @@ -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. | diff --git a/docs/book/src/clusterctl/commands/move.md b/docs/book/src/clusterctl/commands/move.md index bcca2164575d..f6f3ecaf0854 100644 --- a/docs/book/src/clusterctl/commands/move.md +++ b/docs/book/src/clusterctl/commands/move.md @@ -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. diff --git a/docs/book/src/developer/providers/v1.3-to-v1.4.md b/docs/book/src/developer/providers/v1.3-to-v1.4.md index 6ce929a857bb..505818ef6f0c 100644 --- a/docs/book/src/developer/providers/v1.3-to-v1.4.md +++ b/docs/book/src/developer/providers/v1.3-to-v1.4.md @@ -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