cluster-api icon indicating copy to clipboard operation
cluster-api copied to clipboard

✨ clusterctl: Add move --to-folder and --from-folder flags

Open oscr opened this issue 3 years ago • 4 comments

What this PR does / why we need it:

Changes based on #6992

  • Adds deprecated warning to clusterctl restore and clusterctl backup. Example

    $ clusterctl backup --directory ~/temp/clusterctl-backup/
    WARNING: 'clusterctl backup' is deprecated and will be removed in a future release. Use 'clusterctl move' instead.
    Performing backup...
    Discovering Cluster API objects
    Starting backup of Cluster API objects Clusters=1
    Moving Cluster API objects ClusterClasses=1
    Saving files to /home/oscar/temp/clusterctl-backup/
    
  • Adds clusterctl move flags --to-folder and --from-folder. Example

    $ clusterctl move --to-folder --directory ~/temp/clusterctl-backup/
    Performing backup...
    Discovering Cluster API objects
    Starting backup of Cluster API objects Clusters=1
    Moving Cluster API objects ClusterClasses=1
    Saving files to /home/oscar/temp/clusterctl-backup/
    
  • I also added they should mutually exclusive with each other.

    $ clusterctl move --from-folder --to-folder
    Error: if any flags in the group [from-folder to-folder] are set none of the others can be; [from-folder to-folder] were all set
    
    $ clusterctl move --from-folder --kubeconfig=foo
    Error: if any flags in the group [from-folder kubeconfig] are set none of the others can be; [from-folder kubeconfig] were all set
    
    $ clusterctl move --to-folder --to-kubeconfig=foo
    Error: if any flags in the group [to-folder to-kubeconfig] are set none of the others can be; [to-folder to-kubeconfig] were all set
    
  • Since dry-run exists for move but not for restore and backup I added logic to not perform any actions if it's set.

    $ clusterctl move --to-folder --dry-run
    Error: please run --to-folder without --dry-run flag
    $ clusterctl move --from-folder --dry-run
    Error: please run --from-folder without dry-run flag
    

Which issue(s) this PR fixes: Fixes #6992

oscr avatar Aug 02 '22 16:08 oscr

Skipping CI for Draft Pull Request. If you want CI signal for your change, please convert it to an actual PR. You can still manually trigger a test run with /test all

k8s-ci-robot avatar Aug 02 '22 16:08 k8s-ci-robot

@oscr: This issue is currently awaiting triage.

If CAPI contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Aug 02 '22 16:08 k8s-ci-robot

A general question: right now the flags are called --to-folder and --from-folder but the folder is specified with --directory (like in restore and backup). Should we maybe change the names to be consistent?

oscr avatar Aug 16 '22 15:08 oscr

A general question: right now the flags are called --to-folder and --from-folder but the folder is specified with --directory (like in restore and backup). Should we maybe change the names to be consistent?

+1 to using directory instead. We also use directory in the topology dry run cmd

sbueringer avatar Aug 16 '22 17:08 sbueringer

/test pull-cluster-api-e2e-informing-main

oscr avatar Aug 17 '22 13:08 oscr

/retest

oscr avatar Sep 09 '22 16:09 oscr

I seem to have broken some tests with my last "improvement". Will make a fix and push soon.

oscr avatar Sep 09 '22 16:09 oscr

Turns out details are important when programming. I incorrectly replaced a call to Backup as

	return c.Move(MoveOptions{
		FromKubeconfig: options.FromKubeconfig,
		FromDirectory:    options.Directory,
		Namespace:      options.Namespace,
	})

But FromDirectory should have been ToDirectory. So big thanks to whoever wrote the test that caught it.

oscr avatar Sep 10 '22 08:09 oscr

/lgtm

fabriziopandini avatar Sep 12 '22 09:09 fabriziopandini

looking forward to lgtm as soon as lint error is fixed great work!

fabriziopandini avatar Sep 21 '22 19:09 fabriziopandini

@oscr: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-apidiff-main 44f9fd9501bd8aa2e5a77597dd9cc02a09af46e4 link false /test pull-cluster-api-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

k8s-ci-robot avatar Sep 21 '22 22:09 k8s-ci-robot

/lgtm

fabriziopandini avatar Sep 22 '22 19:09 fabriziopandini

/approve Yay!

fabriziopandini avatar Sep 23 '22 09:09 fabriziopandini

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • ~~OWNERS~~ [fabriziopandini]

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Sep 23 '22 09:09 k8s-ci-robot

@ykakarap @fabriziopandini I would like to thank you both for all the help and feedback with this pr. I am grateful for your help :pray:

oscr avatar Sep 23 '22 09:09 oscr