helm reset --force would clean a failed tiller deployment

- [ ] Fixes https://github.com/kubernetes/helm/issues/2441
pull/2461/head
Sushil Kumar 8 years ago
parent f250fce921
commit 62fa6f3d01

@ -57,7 +57,12 @@ func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
Use: "reset", Use: "reset",
Short: "uninstalls Tiller from a cluster", Short: "uninstalls Tiller from a cluster",
Long: resetDesc, Long: resetDesc,
PersistentPreRunE: setupConnection, PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if err := setupConnection(cmd, args); !d.force && err != nil {
return err
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 0 { if len(args) != 0 {
return errors.New("This command does not accept arguments") return errors.New("This command does not accept arguments")
@ -72,7 +77,7 @@ func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
} }
f := cmd.Flags() f := cmd.Flags()
f.BoolVarP(&d.force, "force", "f", false, "forces Tiller uninstall even if there are releases installed") f.BoolVarP(&d.force, "force", "f", false, "forces Tiller uninstall even if there are releases installed, or if tiller is not in ready state")
f.BoolVar(&d.removeHelmHome, "remove-helm-home", false, "if set deletes $HELM_HOME") f.BoolVar(&d.removeHelmHome, "remove-helm-home", false, "if set deletes $HELM_HOME")
return cmd return cmd
@ -91,11 +96,11 @@ func (d *resetCmd) run() error {
res, err := d.client.ListReleases( res, err := d.client.ListReleases(
helm.ReleaseListStatuses([]release.Status_Code{release.Status_DEPLOYED}), helm.ReleaseListStatuses([]release.Status_Code{release.Status_DEPLOYED}),
) )
if err != nil { if !d.force && err != nil {
return prettyError(err) return prettyError(err)
} }
if len(res.Releases) > 0 && !d.force { if !d.force && res != nil && len(res.Releases) > 0 {
return fmt.Errorf("there are still %d deployed releases (Tip: use --force)", len(res.Releases)) return fmt.Errorf("there are still %d deployed releases (Tip: use --force)", len(res.Releases))
} }

Loading…
Cancel
Save