mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 03:19:30 +08:00
CLI: Reduce memory usage for plugin installation (#19639)
* grafana-cli: use tmp file when downloading plugin install file
This commit is contained in:

committed by
Arve Knudsen

parent
46a4118461
commit
b4712ec4b9
@ -1,12 +1,14 @@
|
||||
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, filePath, url string, checksum string) (content []byte, err error)
|
||||
DownloadFileFunc func(pluginName string, tmpFile *os.File, url string, checksum string) (err error)
|
||||
ListAllPluginsFunc func(repoUrl string) (models.PluginRepo, error)
|
||||
}
|
||||
|
||||
@ -18,12 +20,12 @@ func (client *FakeGrafanaComClient) GetPlugin(pluginId, repoUrl string) (models.
|
||||
return models.Plugin{}, nil
|
||||
}
|
||||
|
||||
func (client *FakeGrafanaComClient) DownloadFile(pluginName, filePath, url string, checksum string) (content []byte, err error) {
|
||||
func (client *FakeGrafanaComClient) DownloadFile(pluginName string, tmpFile *os.File, url string, checksum string) (err error) {
|
||||
if client.DownloadFileFunc != nil {
|
||||
return client.DownloadFileFunc(pluginName, filePath, url, checksum)
|
||||
return client.DownloadFileFunc(pluginName, tmpFile, url, checksum)
|
||||
}
|
||||
|
||||
return make([]byte, 0), nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *FakeGrafanaComClient) ListAllPlugins(repoUrl string) (models.PluginRepo, error) {
|
||||
|
Reference in New Issue
Block a user