Chore: Add app URL to the plugin config (#77455)

This commit is contained in:
Andres Martinez Gotor
2023-11-02 13:26:16 +01:00
committed by GitHub
parent 34eb29c3bf
commit 00a596b2e0
4 changed files with 19 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/grafana/grafana-aws-sdk/pkg/awsds"
"github.com/grafana/grafana-azure-sdk-go/azsettings"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/proxy"
"github.com/grafana/grafana-plugin-sdk-go/experimental/featuretoggles"
@@ -79,6 +80,10 @@ func (s *Service) Get(ctx context.Context, p *plugins.Plugin) []string {
func (s *Service) GetConfigMap(ctx context.Context, _ string, _ *auth.ExternalService) map[string]string {
m := make(map[string]string)
if s.cfg.GrafanaAppURL != "" {
m[backend.AppURL] = s.cfg.GrafanaAppURL
}
// TODO add support via plugin SDK
//if externalService != nil {
// m[oauthtokenretriever.AppURL] = s.cfg.GrafanaAppURL

View File

@@ -500,3 +500,14 @@ func TestService_GetConfigMap_featureToggles(t *testing.T) {
}
})
}
func TestService_GetConfigMap_appURL(t *testing.T) {
t.Run("Uses the configured app URL", func(t *testing.T) {
s := &Service{
cfg: &config.Cfg{
GrafanaAppURL: "https://myorg.com/",
},
}
require.Equal(t, map[string]string{"GF_APP_URL": "https://myorg.com/"}, s.GetConfigMap(context.Background(), "", nil))
})
}