From 2048c4a42d8c96d9eadb71fca863050a2237d0c6 Mon Sep 17 00:00:00 2001 From: Alan Zhu Date: Fri, 17 Jun 2022 08:10:53 +0800 Subject: [PATCH] `deinit` add param of `force` Signed-off-by: Alan Zhu --- pkg/karmadactl/deinit.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/karmadactl/deinit.go b/pkg/karmadactl/deinit.go index f052869da..0cfe14c23 100644 --- a/pkg/karmadactl/deinit.go +++ b/pkg/karmadactl/deinit.go @@ -28,6 +28,7 @@ type CommandDeInitOption struct { // DryRun tells if run the command in dry-run mode, without making any server requests. DryRun bool + Force bool KubeClientSet *kubernetes.Clientset } @@ -57,6 +58,7 @@ func NewCmdDeInit(parentCommand string) *cobra.Command { flags.StringVar(&opts.KubeConfig, "kubeconfig", "", "Path to the host cluster kubeconfig file.") flags.StringVar(&opts.Context, "context", "", "The name of the kubeconfig context to use") flags.BoolVar(&opts.DryRun, "dry-run", false, "Run the command in dry-run mode, without making any server requests.") + flags.BoolVarP(&opts.Force, "force", "f", false, "Reset cluster without prompting for confirmation.") return cmd } @@ -282,7 +284,7 @@ func deleteConfirmation() bool { func (o *CommandDeInitOption) Run() error { fmt.Println("removes Karmada from Kubernetes") // delete confirmation,exit the delete action when false. - if !deleteConfirmation() { + if !o.Force && !deleteConfirmation() { return nil }