Plugins: Make grafana-com API URL usage consistent (#86920)

Plugins: Fix grafana-com API URL usage
This commit is contained in:
Hugo Kiyodi Oshiro 2024-04-26 16:47:38 +02:00 committed by GitHub
parent 85c23eed38
commit 7783b16e47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 13 additions and 13 deletions

View File

@ -18,7 +18,7 @@ type PluginManagementCfg struct {
PluginsCDNURLTemplate string
GrafanaComURL string
GrafanaComAPIURL string
GrafanaAppURL string
@ -37,7 +37,7 @@ type Features struct {
// NewPluginManagementCfg returns a new PluginManagementCfg.
func NewPluginManagementCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSettings, pluginsAllowUnsigned []string,
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 {
return &PluginManagementCfg{
PluginsPath: pluginsPath,
@ -46,7 +46,7 @@ func NewPluginManagementCfg(devMode bool, pluginsPath string, pluginSettings set
PluginsAllowUnsigned: pluginsAllowUnsigned,
DisablePlugins: disablePlugins,
PluginsCDNURLTemplate: pluginsCDNURLTemplate,
GrafanaComURL: grafanaComURL,
GrafanaComAPIURL: grafanaComAPIURL,
GrafanaAppURL: appURL,
Features: features,
AngularSupportEnabled: angularSupportEnabled,

View File

@ -22,7 +22,7 @@ type Manager struct {
}
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 {
return nil, err
}

View File

@ -62,7 +62,7 @@ func ProvideDynamic(cfg *setting.Cfg, store angularpatternsstore.Service) (*Dyna
log: log.New("plugin.angulardetectorsprovider.dynamic"),
store: store,
httpClient: makeHttpClient(),
baseURL: cfg.GrafanaComURL,
baseURL: cfg.GrafanaComAPIURL,
backgroundJobInterval: backgroundJobInterval,
}
d.log.Debug("Providing dynamic angular detection patterns", "baseURL", d.baseURL, "interval", d.backgroundJobInterval)

View File

@ -580,7 +580,7 @@ func provideDynamic(t *testing.T, gcomURL string, opts ...provideDynamicOpts) *D
if opt.cfg == nil {
opt.cfg = setting.NewCfg()
}
opt.cfg.GrafanaComURL = gcomURL
opt.cfg.GrafanaComAPIURL = gcomURL + "/api"
d, err := ProvideDynamic(opt.cfg, opt.store)
require.NoError(t, err)
return d

View File

@ -9,7 +9,7 @@ import (
)
// 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.
type GCOMPatternType string

View File

@ -115,7 +115,7 @@ func (kr *KeyRetriever) downloadKeys(ctx context.Context) error {
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 {
return err
}

View File

@ -45,7 +45,7 @@ func Test_PublicKeyUpdate(t *testing.T) {
cfg := &setting.Cfg{}
expectedKey := "fake"
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
cfg.GrafanaComURL = s.URL
cfg.GrafanaComAPIURL = s.URL + "/api"
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
go func() {
err := v.Run(context.Background())
@ -66,7 +66,7 @@ func Test_PublicKeyUpdate(t *testing.T) {
cfg := &setting.Cfg{}
expectedKey := "fake"
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
cfg.GrafanaComURL = s.URL
cfg.GrafanaComAPIURL = s.URL + "/api"
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
go func() {
err := v.Run(context.Background())
@ -86,7 +86,7 @@ func Test_PublicKeyUpdate(t *testing.T) {
cfg := &setting.Cfg{}
expectedKey := "fake"
s, done := setFakeAPIServer(t, expectedKey, "other")
cfg.GrafanaComURL = s.URL
cfg.GrafanaComAPIURL = s.URL + "/api"
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
go func() {
err := v.Run(context.Background())
@ -113,7 +113,7 @@ func Test_PublicKeyUpdate(t *testing.T) {
}
expectedKey := "fake"
s, done := setFakeAPIServer(t, expectedKey, "7e4d0c6a708866e7")
cfg.GrafanaComURL = s.URL
cfg.GrafanaComAPIURL = s.URL + "/api"
v := ProvideService(cfg, keystore.ProvideService(kvstore.NewFakeKVStore()))
// Simulate an updated key
err := v.kv.SetLastUpdated(context.Background())

View File

@ -34,7 +34,7 @@ func ProvidePluginManagementConfig(cfg *setting.Cfg, settingProvider setting.Pro
SkipHostEnvVarsEnabled: features.IsEnabledGlobally(featuremgmt.FlagPluginsSkipHostEnvVars),
},
cfg.AngularSupportEnabled,
cfg.GrafanaComURL,
cfg.GrafanaComAPIURL,
cfg.DisablePlugins,
cfg.HideAngularDeprecation,
cfg.ForwardHostEnvVars,