feat: Prompt before delete (#341)

Resolves #182
This commit is contained in:
KUOKA Yusuke 2018-09-16 22:43:29 +09:00 committed by GitHub
parent 81d796c167
commit c5bc932ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 1 deletions

22
main.go
View File

@ -412,6 +412,10 @@ Do you really want to apply?
Value: "",
Usage: "pass args to helm exec",
},
cli.BoolFlag{
Name: "auto-approve",
Usage: "Skip interactive approval before deleting",
},
cli.BoolFlag{
Name: "purge",
Usage: "purge releases i.e. free release names and histories",
@ -430,7 +434,23 @@ Do you really want to apply?
helm.SetHelmBinary(c.GlobalString("helm-binary"))
}
return state.DeleteReleases(helm, purge)
names := make([]string, len(state.Releases))
for i, r := range state.Releases {
names[i] = fmt.Sprintf(" %s (%s)", r.Name, r.Chart)
}
msg := fmt.Sprintf(`Affected releases are:
%s
Do you really want to delete?
Helmfile will delete all your releases, as shown above.
`, strings.Join(names, "\n"))
autoApprove := c.Bool("auto-approve")
if autoApprove || !autoApprove && askForConfirmation(msg) {
return state.DeleteReleases(helm, purge)
}
return nil
})
},
},