MCPcopy
hub / github.com/helm/helm / uninstallPlugin

Function uninstallPlugin

pkg/cmd/plugin_uninstall.go:87–122  ·  view source on GitHub ↗
(p plugin.Plugin)

Source from the content-addressed store, hash-verified

85}
86
87func uninstallPlugin(p plugin.Plugin) error {
88 if err := os.RemoveAll(p.Dir()); err != nil {
89 return err
90 }
91
92 // Clean up versioned tarball and provenance files from HELM_PLUGINS directory
93 // These files are saved with pattern: PLUGIN_NAME-VERSION.tgz and PLUGIN_NAME-VERSION.tgz.prov
94 pluginName := p.Metadata().Name
95 pluginVersion := p.Metadata().Version
96 pluginsDir := settings.PluginsDirectory
97
98 // Remove versioned files: plugin-name-version.tgz and plugin-name-version.tgz.prov
99 if pluginVersion != "" {
100 versionedBasename := fmt.Sprintf("%s-%s.tgz", pluginName, pluginVersion)
101
102 // Remove tarball file
103 tarballPath := filepath.Join(pluginsDir, versionedBasename)
104 if _, err := os.Stat(tarballPath); err == nil {
105 slog.Debug("removing versioned tarball", "path", tarballPath)
106 if err := os.Remove(tarballPath); err != nil {
107 slog.Debug("failed to remove tarball file", "path", tarballPath, "error", err)
108 }
109 }
110
111 // Remove provenance file
112 provPath := filepath.Join(pluginsDir, versionedBasename+".prov")
113 if _, err := os.Stat(provPath); err == nil {
114 slog.Debug("removing versioned provenance", "path", provPath)
115 if err := os.Remove(provPath); err != nil {
116 slog.Debug("failed to remove provenance file", "path", provPath, "error", err)
117 }
118 }
119 }
120
121 return runHook(p, plugin.Delete)
122}
123
124// TODO should this be in pkg/plugin/loader.go?
125func findPlugin(plugins []plugin.Plugin, name string) plugin.Plugin {

Callers 1

runMethod · 0.85

Calls 4

runHookFunction · 0.85
DirMethod · 0.65
MetadataMethod · 0.65
RemoveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…