github.com/uhthomas/helm@v3.0.0-beta.3+incompatible/cmd/helm/uninstall.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "fmt" 21 "io" 22 "time" 23 24 "github.com/spf13/cobra" 25 26 "helm.sh/helm/cmd/helm/require" 27 "helm.sh/helm/pkg/action" 28 ) 29 30 const uninstallDesc = ` 31 This command takes a release name and uninstalls the release. 32 33 It removes all of the resources associated with the last release of the chart 34 as well as the release history, freeing it up for future use. 35 36 Use the '--dry-run' flag to see which releases will be uninstalled without actually 37 uninstalling them. 38 ` 39 40 func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 41 client := action.NewUninstall(cfg) 42 43 cmd := &cobra.Command{ 44 Use: "uninstall RELEASE_NAME [...]", 45 Aliases: []string{"del", "delete", "un"}, 46 SuggestFor: []string{"remove", "rm"}, 47 Short: "uninstall a release", 48 Long: uninstallDesc, 49 Args: require.MinimumNArgs(1), 50 RunE: func(cmd *cobra.Command, args []string) error { 51 for i := 0; i < len(args); i++ { 52 53 res, err := client.Run(args[i]) 54 if err != nil { 55 return err 56 } 57 if res != nil && res.Info != "" { 58 fmt.Fprintln(out, res.Info) 59 } 60 61 fmt.Fprintf(out, "release \"%s\" uninstalled\n", args[i]) 62 } 63 return nil 64 }, 65 } 66 67 f := cmd.Flags() 68 f.BoolVar(&client.DryRun, "dry-run", false, "simulate a uninstall") 69 f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation") 70 f.BoolVar(&client.KeepHistory, "keep-history", false, "remove all associated resources and mark the release as deleted, but retain the release history") 71 f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") 72 73 return cmd 74 }