Plugins: Pass PDC info as file paths (#85239)

* pass filepaths

* fix test
This commit is contained in:
Will Browne
2024-03-27 15:21:05 +01:00
committed by GitHub
parent 61e67423ff
commit cd912367b3
2 changed files with 14 additions and 14 deletions

View File

@@ -73,9 +73,9 @@ func (s *RequestConfigProvider) PluginRequestConfig(ctx context.Context, pluginI
if s.cfg.ProxySettings.Enabled { if s.cfg.ProxySettings.Enabled {
m[proxy.PluginSecureSocksProxyEnabled] = "true" m[proxy.PluginSecureSocksProxyEnabled] = "true"
m[proxy.PluginSecureSocksProxyClientCert] = s.cfg.ProxySettings.ClientCert m[proxy.PluginSecureSocksProxyClientCert] = s.cfg.ProxySettings.ClientCertFilePath
m[proxy.PluginSecureSocksProxyClientKey] = s.cfg.ProxySettings.ClientKey m[proxy.PluginSecureSocksProxyClientKey] = s.cfg.ProxySettings.ClientKeyFilePath
m[proxy.PluginSecureSocksProxyRootCAs] = strings.Join(s.cfg.ProxySettings.RootCAs, ",") m[proxy.PluginSecureSocksProxyRootCAs] = strings.Join(s.cfg.ProxySettings.RootCAFilePaths, " ")
m[proxy.PluginSecureSocksProxyProxyAddress] = s.cfg.ProxySettings.ProxyAddress m[proxy.PluginSecureSocksProxyProxyAddress] = s.cfg.ProxySettings.ProxyAddress
m[proxy.PluginSecureSocksProxyServerName] = s.cfg.ProxySettings.ServerName m[proxy.PluginSecureSocksProxyServerName] = s.cfg.ProxySettings.ServerName
m[proxy.PluginSecureSocksProxyAllowInsecure] = strconv.FormatBool(s.cfg.ProxySettings.AllowInsecure) m[proxy.PluginSecureSocksProxyAllowInsecure] = strconv.FormatBool(s.cfg.ProxySettings.AllowInsecure)

View File

@@ -35,23 +35,23 @@ func TestRequestConfigProvider_PluginRequestConfig(t *testing.T) {
name: "Both features and proxy settings enabled", name: "Both features and proxy settings enabled",
cfg: &PluginInstanceCfg{ cfg: &PluginInstanceCfg{
ProxySettings: setting.SecureSocksDSProxySettings{ ProxySettings: setting.SecureSocksDSProxySettings{
Enabled: true, Enabled: true,
ShowUI: true, ShowUI: true,
ClientCert: "c3rt", ClientCertFilePath: "./c3rt",
ClientKey: "k3y", ClientKeyFilePath: "./k3y",
RootCAs: []string{"ca"}, RootCAFilePaths: []string{"./ca"},
ProxyAddress: "https://proxy.grafana.com", ProxyAddress: "https://proxy.grafana.com",
ServerName: "secureProxy", ServerName: "secureProxy",
AllowInsecure: true, AllowInsecure: true,
}, },
Features: featuremgmt.WithFeatures("feat-2", "feat-500", "feat-1"), Features: featuremgmt.WithFeatures("feat-2", "feat-500", "feat-1"),
}, },
expected: map[string]string{ expected: map[string]string{
"GF_INSTANCE_FEATURE_TOGGLES_ENABLE": "feat-1,feat-2,feat-500", "GF_INSTANCE_FEATURE_TOGGLES_ENABLE": "feat-1,feat-2,feat-500",
"GF_SECURE_SOCKS_DATASOURCE_PROXY_SERVER_ENABLED": "true", "GF_SECURE_SOCKS_DATASOURCE_PROXY_SERVER_ENABLED": "true",
"GF_SECURE_SOCKS_DATASOURCE_PROXY_CLIENT_CERT": "c3rt", "GF_SECURE_SOCKS_DATASOURCE_PROXY_CLIENT_CERT": "./c3rt",
"GF_SECURE_SOCKS_DATASOURCE_PROXY_CLIENT_KEY": "k3y", "GF_SECURE_SOCKS_DATASOURCE_PROXY_CLIENT_KEY": "./k3y",
"GF_SECURE_SOCKS_DATASOURCE_PROXY_ROOT_CA_CERT": "ca", "GF_SECURE_SOCKS_DATASOURCE_PROXY_ROOT_CA_CERT": "./ca",
"GF_SECURE_SOCKS_DATASOURCE_PROXY_PROXY_ADDRESS": "https://proxy.grafana.com", "GF_SECURE_SOCKS_DATASOURCE_PROXY_PROXY_ADDRESS": "https://proxy.grafana.com",
"GF_SECURE_SOCKS_DATASOURCE_PROXY_SERVER_NAME": "secureProxy", "GF_SECURE_SOCKS_DATASOURCE_PROXY_SERVER_NAME": "secureProxy",
"GF_SECURE_SOCKS_DATASOURCE_PROXY_ALLOW_INSECURE": "true", "GF_SECURE_SOCKS_DATASOURCE_PROXY_ALLOW_INSECURE": "true",