mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CLI: Allow installing custom binary plugins (#17551)
Make sure all data is sent to API to be able to select correct archive version.
This commit is contained in:
34
pkg/cmd/grafana-cli/commands/commandstest/fake_api_client.go
Normal file
34
pkg/cmd/grafana-cli/commands/commandstest/fake_api_client.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package commandstest
|
||||
|
||||
import (
|
||||
"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)
|
||||
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, filePath, url string, checksum string) (content []byte, err error) {
|
||||
if client.DownloadFileFunc != nil {
|
||||
return client.DownloadFileFunc(pluginName, filePath, url, checksum)
|
||||
}
|
||||
|
||||
return make([]byte, 0), nil
|
||||
}
|
||||
|
||||
func (client *FakeGrafanaComClient) ListAllPlugins(repoUrl string) (models.PluginRepo, error) {
|
||||
if client.ListAllPluginsFunc != nil {
|
||||
return client.ListAllPluginsFunc(repoUrl)
|
||||
}
|
||||
return models.PluginRepo{}, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package commandstest
|
||||
|
||||
import (
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
|
||||
)
|
||||
|
||||
type FakeFlagger struct {
|
||||
@@ -12,6 +13,7 @@ type FakeCommandLine struct {
|
||||
LocalFlags, GlobalFlags *FakeFlagger
|
||||
HelpShown, VersionShown bool
|
||||
CliArgs []string
|
||||
Client utils.ApiClient
|
||||
}
|
||||
|
||||
func (ff FakeFlagger) String(key string) string {
|
||||
@@ -105,3 +107,7 @@ func (fcli *FakeCommandLine) PluginDirectory() string {
|
||||
func (fcli *FakeCommandLine) PluginURL() string {
|
||||
return fcli.GlobalString("pluginUrl")
|
||||
}
|
||||
|
||||
func (fcli *FakeCommandLine) ApiClient() utils.ApiClient {
|
||||
return fcli.Client
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user