<commit_before>/*
Copyright The Helm Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
	"errors"
	"fmt"
	"io"
	"os"

	"github.com/spf13/cobra"

	"k8s.io/client-go/kubernetes"

	"k8s.io/helm/cmd/helm/installer"
	"k8s.io/helm/pkg/helm"
	"k8s.io/helm/pkg/helm/helmpath"
	"k8s.io/helm/pkg/proto/hapi/release"
)

const resetDesc = `
This command uninstalls Tiller (the Helm server-side component) from your
Kubernetes Cluster and optionally deletes local configuration in
$HELM_HOME (default ~/.helm/)
`

type resetCmd struct {
	force          bool
	removeHelmHome bool
	namespace      string
	out            io.Writer
	home           helmpath.Home
	client         helm.Interface
	kubeClient     kubernetes.Interface
}

func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
	d := &resetCmd{
		out:    out,
		client: client,
	}

	cmd := &cobra.Command{
		Use:   "reset",
		Short: "uninstalls Tiller from a cluster",
		Long:  resetDesc,
		PreRunE: func(cmd *cobra.Command, args []string) error {
			if err := setupConnection(); !d.force && err != nil {
				return err
			}
			return nil
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			if len(args) != 0 {
				return errors.New("This command does not accept arguments")
			}

			d.namespace = settings.TillerNamespace
			d.home = settings.Home
			d.client = ensureHelmClient(d.client)

			return d.run()
		},
	}

	f := cmd.Flags()
	settings.AddFlagsTLS(f)
	f.BoolVarP(&d.force, "force", "f", false, "forces Tiller uninstall even if there are releases installed, or if Tiller is not in ready state. Releases are not deleted.)")
	f.BoolVar(&d.removeHelmHome, "remove-helm-home", false, "if set deletes $HELM_HOME")

	// set defaults from environment
	settings.InitTLS(f)

	return cmd
}<commit_msg>Fix reset force which hangs Tiller pod removed<commit_after>/*
Copyright The Helm Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
	"errors"
	"fmt"
	"io"
	"os"
	"strings"

	"github.com/spf13/cobra"

	"k8s.io/client-go/kubernetes"

	"k8s.io/helm/cmd/helm/installer"
	"k8s.io/helm/pkg/helm"
	"k8s.io/helm/pkg/helm/helmpath"
	"k8s.io/helm/pkg/proto/hapi/release"
)

const resetDesc = `
This command uninstalls Tiller (the Helm server-side component) from your
Kubernetes Cluster and optionally deletes local configuration in
$HELM_HOME (default ~/.helm/)
`

type resetCmd struct {
	force          bool
	removeHelmHome bool
	namespace      string
	out            io.Writer
	home           helmpath.Home
	client         helm.Interface
	kubeClient     kubernetes.Interface
}

func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
	d := &resetCmd{
		out:    out,
		client: client,
	}

	cmd := &cobra.Command{
		Use:   "reset",
		Short: "uninstalls Tiller from a cluster",
		Long:  resetDesc,
		PreRunE: func(cmd *cobra.Command, args []string) error {
			err := setupConnection()
			if !d.force && err != nil {
				return err
			}
			if d.force && err != nil && strings.EqualFold(err.Error(), "could not find tiller") {
				return err
			}
			return nil
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			if len(args) != 0 {
				return errors.New("This command does not accept arguments")
			}

			d.namespace = settings.TillerNamespace
			d.home = settings.Home
			d.client = ensureHelmClient(d.client)

			return d.run()
		},
	}

	f := cmd.Flags()
	settings.AddFlagsTLS(f)
	f.BoolVarP(&d.force, "force", "f", false, "forces Tiller uninstall even if there are releases installed, or if Tiller is not in ready state. Releases are not deleted.)")
	f.BoolVar(&d.removeHelmHome, "remove-helm-home", false, "if set deletes $HELM_HOME")

	// set defaults from environment
	settings.InitTLS(f)

	return cmd
}
{'fraction_non_alphanumeric': 0.10616656071201526, 'fraction_numerical': 0.0050858232676414495, 'mean_word_length': 3.4866920152091256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7083719', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1534, 'n_words': 503}