MCPcopy Index your code
hub / github.com/cloudfoundry/cli / Execute

Method Execute

cf/commands/plugin/uninstall_plugin.go:68–102  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

66}
67
68func (cmd *PluginUninstall) Execute(c flags.FlagContext) error {
69 pluginName := c.Args()[0]
70 pluginNameMap := map[string]interface{}{"PluginName": pluginName}
71
72 cmd.ui.Say(T("Uninstalling plugin {{.PluginName}}...", pluginNameMap))
73
74 plugins := cmd.config.Plugins()
75
76 if _, ok := plugins[pluginName]; !ok {
77 return errors.New(T("Plugin name {{.PluginName}} does not exist", pluginNameMap))
78 }
79
80 pluginMetadata := plugins[pluginName]
81
82 warn, err := cmd.notifyPluginUninstalling(pluginMetadata)
83 if err != nil {
84 return err
85 }
86 if warn != nil {
87 cmd.ui.Say("Error invoking plugin: " + warn.Error() + ". Process to uninstall ...")
88 }
89
90 time.Sleep(500 * time.Millisecond) // prevent 'process being used' error in Windows
91
92 err = os.Remove(pluginMetadata.Location)
93 if err != nil {
94 cmd.ui.Warn("Error removing plugin binary: " + err.Error())
95 }
96
97 cmd.config.RemovePlugin(pluginName)
98
99 cmd.ui.Ok()
100 cmd.ui.Say(T("Plugin {{.PluginName}} successfully uninstalled.", pluginNameMap))
101 return nil
102}
103
104func (cmd *PluginUninstall) notifyPluginUninstalling(meta pluginconfig.PluginMetadata) (error, error) {
105 err := cmd.rpcService.Start()

Callers

nothing calls this directly

Calls 8

ArgsMethod · 0.65
SayMethod · 0.65
PluginsMethod · 0.65
ErrorMethod · 0.65
WarnMethod · 0.65
RemovePluginMethod · 0.65
OkMethod · 0.65

Tested by

no test coverage detected