Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Add --confirm flag to delete component without asking for confirmat…
Browse files Browse the repository at this point in the history
…ion which fixes #495

Signed-off-by: knrt10 <kautilya@kinvolk.io>
  • Loading branch information
knrt10 committed Jun 5, 2020
1 parent 19cb54a commit 1659740
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cli/cmd/component-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ When run with no arguments, all components listed in the configuration are delet
}

var deleteNamespace bool
var confirmDeleteComponent bool

// nolint:gochecknoinits
func init() {
componentCmd.AddCommand(componentDeleteCmd)
pf := componentDeleteCmd.PersistentFlags()
pf.BoolVarP(&deleteNamespace, "delete-namespace", "", false, "Delete namespace with component.")
pf.BoolVarP(&confirmDeleteComponent, "confirm", "", false, "Delete component without asking for confirmation.")
}

func runDelete(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -79,14 +81,16 @@ func runDelete(cmd *cobra.Command, args []string) {
componentsObjects[i] = compObj
}

if !askForConfirmation(
fmt.Sprintf(
"The following components will be deleted:\n\t%s\n\nAre you sure you want to proceed?",
strings.Join(componentsToDelete, "\n\t"),
),
) {
contextLogger.Info("Components deletion cancelled.")
return
if !confirmDeleteComponent {
if !askForConfirmation(
fmt.Sprintf(
"The following components will be deleted:\n\t%s\n\nAre you sure you want to proceed?",
strings.Join(componentsToDelete, "\n\t"),
),
) {
contextLogger.Info("Components deletion cancelled.")
return
}
}

kubeconfig, err := getKubeconfig()
Expand Down

0 comments on commit 1659740

Please sign in to comment.