2016-02-15 21:09:34 +08:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2023-05-03 20:52:57 +08:00
|
|
|
"context"
|
2016-02-15 21:09:34 +08:00
|
|
|
"errors"
|
2016-04-19 14:32:23 +08:00
|
|
|
"fmt"
|
2016-06-25 07:18:49 +08:00
|
|
|
"strings"
|
2018-04-19 01:04:37 +08:00
|
|
|
|
2019-05-27 16:47:21 +08:00
|
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
|
2016-02-15 21:09:34 +08:00
|
|
|
)
|
|
|
|
|
2023-05-04 16:52:09 +08:00
|
|
|
func removeCommand(c utils.CommandLine) error {
|
2023-05-03 20:52:57 +08:00
|
|
|
pluginID := c.Args().First()
|
|
|
|
if pluginID == "" {
|
2020-02-26 19:27:31 +08:00
|
|
|
return errors.New("missing plugin parameter")
|
2016-02-15 21:09:34 +08:00
|
|
|
}
|
|
|
|
|
2023-05-03 20:52:57 +08:00
|
|
|
err := uninstallPlugin(context.Background(), pluginID, c)
|
2016-06-25 07:18:49 +08:00
|
|
|
if err != nil {
|
|
|
|
if strings.Contains(err.Error(), "no such file or directory") {
|
2020-02-26 19:27:31 +08:00
|
|
|
return fmt.Errorf("plugin does not exist")
|
2016-02-15 21:09:34 +08:00
|
|
|
}
|
2016-06-25 07:18:49 +08:00
|
|
|
return err
|
2023-02-22 16:24:13 +08:00
|
|
|
} else {
|
|
|
|
logRestartNotice()
|
2016-02-15 21:09:34 +08:00
|
|
|
}
|
|
|
|
|
2016-06-25 07:18:49 +08:00
|
|
|
return nil
|
2016-02-15 21:09:34 +08:00
|
|
|
}
|