MCPcopy Index your code
hub / github.com/helm/helm / newUninstallCmd

Function newUninstallCmd

pkg/cmd/uninstall.go:43–88  ·  view source on GitHub ↗
(cfg *action.Configuration, out io.Writer)

Source from the content-addressed store, hash-verified

41`
42
43func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
44 client := action.NewUninstall(cfg)
45
46 cmd := &cobra.Command{
47 Use: "uninstall RELEASE_NAME [...]",
48 Aliases: []string{"del", "delete", "un"},
49 SuggestFor: []string{"remove", "rm"},
50 Short: "uninstall a release",
51 Long: uninstallDesc,
52 Args: require.MinimumNArgs(1),
53 ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
54 return compListReleases(toComplete, args, cfg)
55 },
56 RunE: func(_ *cobra.Command, args []string) error {
57 validationErr := validateCascadeFlag(client)
58 if validationErr != nil {
59 return validationErr
60 }
61 for i := range args {
62
63 res, err := client.Run(args[i])
64 if err != nil {
65 return err
66 }
67 if res != nil && res.Info != "" {
68 fmt.Fprintln(out, res.Info)
69 }
70
71 fmt.Fprintf(out, "release \"%s\" uninstalled\n", args[i])
72 }
73 return nil
74 },
75 }
76
77 f := cmd.Flags()
78 f.BoolVar(&client.DryRun, "dry-run", false, "simulate a uninstall")
79 f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation")
80 f.BoolVar(&client.IgnoreNotFound, "ignore-not-found", false, `Treat "release not found" as a successful uninstall`)
81 f.BoolVar(&client.KeepHistory, "keep-history", false, "remove all associated resources and mark the release as deleted, but retain the release history")
82 f.StringVar(&client.DeletionPropagation, "cascade", "background", "Must be \"background\", \"orphan\", or \"foreground\". Selects the deletion cascading strategy for the dependents. Defaults to background. Use \"foreground\" with --wait to ensure resources with finalizers are fully deleted before returning.")
83 f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
84 f.StringVar(&client.Description, "description", "", "add a custom description")
85 AddWaitFlag(cmd, &client.WaitStrategy)
86
87 return cmd
88}
89
90func validateCascadeFlag(client *action.Uninstall) error {
91 if client.DeletionPropagation != "background" && client.DeletionPropagation != "foreground" && client.DeletionPropagation != "orphan" {

Callers 1

newRootCmdWithConfigFunction · 0.85

Calls 6

RunMethod · 0.95
NewUninstallFunction · 0.92
MinimumNArgsFunction · 0.92
compListReleasesFunction · 0.85
validateCascadeFlagFunction · 0.85
AddWaitFlagFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…