mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Make grafana-com API URL usage consistent (#86920)
Plugins: Fix grafana-com API URL usage
This commit is contained in:
parent
85c23eed38
commit
7783b16e47
@ -18,7 +18,7 @@ type PluginManagementCfg struct {
|
|||||||
|
|
||||||
PluginsCDNURLTemplate string
|
PluginsCDNURLTemplate string
|
||||||
|
|
||||||
GrafanaComURL string
|
GrafanaComAPIURL string
|
||||||
|
|
||||||
GrafanaAppURL string
|
GrafanaAppURL string
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ type Features struct {
|
|||||||
// NewPluginManagementCfg returns a new PluginManagementCfg.
|
// NewPluginManagementCfg returns a new PluginManagementCfg.
|
||||||
func NewPluginManagementCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSettings, pluginsAllowUnsigned []string,
|
func NewPluginManagementCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSettings, pluginsAllowUnsigned []string,
|
||||||
pluginsCDNURLTemplate string, appURL string, features Features, angularSupportEnabled bool,
|
pluginsCDNURLTemplate string, appURL string, features Features, angularSupportEnabled bool,
|
||||||
grafanaComURL string, disablePlugins []string, hideAngularDeprecation []string, forwardHostEnvVars []string,
|
grafanaComAPIURL string, disablePlugins []string, hideAngularDeprecation []string, forwardHostEnvVars []string,
|
||||||
) *PluginManagementCfg {
|
) *PluginManagementCfg {
|
||||||
return &PluginManagementCfg{
|
return &PluginManagementCfg{
|
||||||
PluginsPath: pluginsPath,
|
PluginsPath: pluginsPath,
|
||||||
@ -46,7 +46,7 @@ func NewPluginManagementCfg(devMode bool, pluginsPath string, pluginSettings set
|
|||||||
PluginsAllowUnsigned: pluginsAllowUnsigned,
|
PluginsAllowUnsigned: pluginsAllowUnsigned,
|
||||||
DisablePlugins: disablePlugins,
|
DisablePlugins: disablePlugins,
|
||||||
PluginsCDNURLTemplate: pluginsCDNURLTemplate,
|
PluginsCDNURLTemplate: pluginsCDNURLTemplate,
|
||||||
GrafanaComURL: grafanaComURL,
|
GrafanaComAPIURL: grafanaComAPIURL,
|
||||||
GrafanaAppURL: appURL,
|
GrafanaAppURL: appURL,
|
||||||
Features: features,
|
Features: features,
|
||||||
AngularSupportEnabled: angularSupportEnabled,
|
AngularSupportEnabled: angularSupportEnabled,
|
||||||
|
@ -22,7 +22,7 @@ type Manager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ProvideService(cfg *config.PluginManagementCfg) (*Manager, error) {
|
func ProvideService(cfg *config.PluginManagementCfg) (*Manager, error) {
|
||||||
baseURL, err := url.JoinPath(cfg.GrafanaComURL, "/api/plugins")
|
baseURL, err := url.JoinPath(cfg.GrafanaComAPIURL, "/plugins")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func ProvideDynamic(cfg *setting.Cfg, store angularpatternsstore.Service) (*Dyna
|
|||||||
log: log.New("plugin.angulardetectorsprovider.dynamic"),
|
log: log.New("plugin.angulardetectorsprovider.dynamic"),
|
||||||
store: store,
|
store: store,
|
||||||
httpClient: makeHttpClient(),
|
httpClient: makeHttpClient(),
|
||||||
baseURL: cfg.GrafanaComURL,
|
baseURL: cfg.GrafanaComAPIURL,
|
||||||
backgroundJobInterval: backgroundJobInterval,
|
backgroundJobInterval: backgroundJobInterval,
|
||||||
}
|
}
|
||||||
d.log.Debug("Providing dynamic angular detection patterns", "baseURL", d.baseURL, "interval", d.backgroundJobInterval)
|
d.log.Debug("Providing dynamic angular detection patterns", "baseURL", d.baseURL, "interval", d.backgroundJobInterval)
|
||||||
|
@ -580,7 +580,7 @@ func provideDynamic(t *testing.T, gcomURL string, opts ...provideDynamicOpts) *D
|
|||||||
if opt.cfg == nil {
|
if opt.cfg == nil {
|
||||||
opt.cfg = setting.NewCfg()
|
opt.cfg = setting.NewCfg()
|
||||||
}
|
}
|
||||||
opt.cfg.GrafanaComURL = gcomURL
|
opt.cfg.GrafanaComAPIURL = gcomURL + "/api"
|
||||||
d, err := ProvideDynamic(opt.cfg, opt.store)
|
d, err := ProvideDynamic(opt.cfg, opt.store)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return d
|
return d
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// gcomAngularPatternsPath is the relative path to the GCOM API handler that returns angular detection patterns.
|
// gcomAngularPatternsPath is the relative path to the GCOM API handler that returns angular detection patterns.
|
||||||
const gcomAngularPatternsPath = "/api/plugins/angular_patterns"
|
const gcomAngularPatternsPath = "/plugins/angular_patterns"
|
||||||
|
|
||||||
// GCOMPatternType is a pattern type returned by the GCOM API.
|
// GCOMPatternType is a pattern type returned by the GCOM API.
|
||||||
type GCOMPatternType string
|
type GCOMPatternType string
|
||||||
|
@ -115,7 +115,7 @@ func (kr *KeyRetriever) downloadKeys(ctx context.Context) error {
|
|||||||
Items []ManifestKeys
|
Items []ManifestKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
url, err := url.JoinPath(kr.cfg.GrafanaComURL, "/api/plugins/ci/keys") // nolint:gosec URL is provided by config
|
url, err := url.JoinPath(kr.cfg.GrafanaComAPIURL, "/plugins/ci/keys") // nolint:gosec URL is provided by config
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func Test_PublicKeyUpdate(t *testing.T) {
|
|||||||
cfg := &setting.Cfg{}
|
cfg := &setting.Cfg{}
|
||||||
expectedKey := "fake"
|
expectedKey := "fake"
|
||||||
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
|
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
|
||||||
cfg.GrafanaComURL = s.URL
|
cfg.GrafanaComAPIURL = s.URL + "/api"
|
||||||
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
|
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
|
||||||
go func() {
|
go func() {
|
||||||
err := v.Run(context.Background())
|
err := v.Run(context.Background())
|
||||||
@ -66,7 +66,7 @@ func Test_PublicKeyUpdate(t *testing.T) {
|
|||||||
cfg := &setting.Cfg{}
|
cfg := &setting.Cfg{}
|
||||||
expectedKey := "fake"
|
expectedKey := "fake"
|
||||||
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
|
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
|
||||||
cfg.GrafanaComURL = s.URL
|
cfg.GrafanaComAPIURL = s.URL + "/api"
|
||||||
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
|
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
|
||||||
go func() {
|
go func() {
|
||||||
err := v.Run(context.Background())
|
err := v.Run(context.Background())
|
||||||
@ -86,7 +86,7 @@ func Test_PublicKeyUpdate(t *testing.T) {
|
|||||||
cfg := &setting.Cfg{}
|
cfg := &setting.Cfg{}
|
||||||
expectedKey := "fake"
|
expectedKey := "fake"
|
||||||
s, done := setFakeAPIServer(t, expectedKey, "other")
|
s, done := setFakeAPIServer(t, expectedKey, "other")
|
||||||
cfg.GrafanaComURL = s.URL
|
cfg.GrafanaComAPIURL = s.URL + "/api"
|
||||||
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
|
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
|
||||||
go func() {
|
go func() {
|
||||||
err := v.Run(context.Background())
|
err := v.Run(context.Background())
|
||||||
@ -113,7 +113,7 @@ func Test_PublicKeyUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
expectedKey := "fake"
|
expectedKey := "fake"
|
||||||
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
|
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
|
||||||
cfg.GrafanaComURL = s.URL
|
cfg.GrafanaComAPIURL = s.URL + "/api"
|
||||||
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
|
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
|
||||||
// Simulate an updated key
|
// Simulate an updated key
|
||||||
err := v.kv.SetLastUpdated(context.Background())
|
err := v.kv.SetLastUpdated(context.Background())
|
||||||
|
@ -34,7 +34,7 @@ func ProvidePluginManagementConfig(cfg *setting.Cfg, settingProvider setting.Pro
|
|||||||
SkipHostEnvVarsEnabled: features.IsEnabledGlobally(featuremgmt.FlagPluginsSkipHostEnvVars),
|
SkipHostEnvVarsEnabled: features.IsEnabledGlobally(featuremgmt.FlagPluginsSkipHostEnvVars),
|
||||||
},
|
},
|
||||||
cfg.AngularSupportEnabled,
|
cfg.AngularSupportEnabled,
|
||||||
cfg.GrafanaComURL,
|
cfg.GrafanaComAPIURL,
|
||||||
cfg.DisablePlugins,
|
cfg.DisablePlugins,
|
||||||
cfg.HideAngularDeprecation,
|
cfg.HideAngularDeprecation,
|
||||||
cfg.ForwardHostEnvVars,
|
cfg.ForwardHostEnvVars,
|
||||||
|
Loading…
Reference in New Issue
Block a user