Plugins: Improve grafana-cli UX + API response messaging for plugin install incompatibility scenario (#36556)

* improve UX for plugin install incompatability

* refactor test
This commit is contained in:
Will Browne
2021-07-13 00:58:46 -07:00
committed by GitHub
parent 81511e34d9
commit e06335ffe9
3 changed files with 38 additions and 36 deletions

View File

@ -387,8 +387,9 @@ func (hs *HTTPServer) InstallPlugin(c *models.ReqContext, dto dtos.InstallPlugin
if errors.As(err, &versionNotFoundErr) {
return response.Error(http.StatusNotFound, "Plugin version not found", err)
}
if errors.Is(err, installer.ErrPluginNotFound) {
return response.Error(http.StatusNotFound, "Plugin not found", err)
var clientError installer.Response4xxError
if errors.As(err, &clientError) {
return response.Error(clientError.StatusCode, clientError.Message, err)
}
if errors.Is(err, plugins.ErrInstallCorePlugin) {
return response.Error(http.StatusForbidden, "Cannot install or change a Core plugin", err)