Files
Olivier Lemasle b4712ec4b9 CLI: Reduce memory usage for plugin installation (#19639)
* grafana-cli: use tmp file when downloading plugin install file
2019-11-06 13:42:58 +01:00

37 lines
1.0 KiB
Go

package commandstest
import (
"os"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
)
type FakeGrafanaComClient struct {
GetPluginFunc func(pluginId, repoUrl string) (models.Plugin, error)
DownloadFileFunc func(pluginName string, tmpFile *os.File, url string, checksum string) (err error)
ListAllPluginsFunc func(repoUrl string) (models.PluginRepo, error)
}
func (client *FakeGrafanaComClient) GetPlugin(pluginId, repoUrl string) (models.Plugin, error) {
if client.GetPluginFunc != nil {
return client.GetPluginFunc(pluginId, repoUrl)
}
return models.Plugin{}, nil
}
func (client *FakeGrafanaComClient) DownloadFile(pluginName string, tmpFile *os.File, url string, checksum string) (err error) {
if client.DownloadFileFunc != nil {
return client.DownloadFileFunc(pluginName, tmpFile, url, checksum)
}
return nil
}
func (client *FakeGrafanaComClient) ListAllPlugins(repoUrl string) (models.PluginRepo, error) {
if client.ListAllPluginsFunc != nil {
return client.ListAllPluginsFunc(repoUrl)
}
return models.PluginRepo{}, nil
}