mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 13:52:12 +08:00
Plugins: Allow disabling "skip host environment variables" per-plugin (#78266)
* Plugins: Allow disabling skipping host environment variables per-plugin * Renamed SkipEnvVarsDecorateFunc to SkipHostEnvVarsDecorateFunc * PR review feedback * fix tests
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/config"
|
||||
"github.com/grafana/grafana/pkg/plugins/log"
|
||||
"github.com/grafana/grafana/pkg/plugins/manager/loader/assetpath"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
)
|
||||
|
||||
// DefaultConstructor implements the default ConstructFunc used for the Construct step of the Bootstrap stage.
|
||||
@ -32,6 +33,7 @@ func DefaultDecorateFuncs(cfg *config.Cfg) []DecorateFunc {
|
||||
AppDefaultNavURLDecorateFunc,
|
||||
TemplateDecorateFunc,
|
||||
AppChildDecorateFunc(cfg),
|
||||
SkipHostEnvVarsDecorateFunc(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,3 +155,14 @@ func configureAppChildPlugin(cfg *config.Cfg, parent *plugins.Plugin, child *plu
|
||||
child.Module = path.Join("/", cfg.GrafanaAppSubURL, "/public/plugins", parent.ID, appSubPath, "module.js")
|
||||
}
|
||||
}
|
||||
|
||||
// SkipHostEnvVarsDecorateFunc returns a DecorateFunc that configures the SkipHostEnvVars field of the plugin.
|
||||
// It will be set to true if the FlagPluginsSkipHostEnvVars feature flag is set, and the plugin does not have
|
||||
// forward_host_env_vars = true in its plugin settings.
|
||||
func SkipHostEnvVarsDecorateFunc(cfg *config.Cfg) DecorateFunc {
|
||||
return func(_ context.Context, p *plugins.Plugin) (*plugins.Plugin, error) {
|
||||
p.SkipHostEnvVars = cfg.Features.IsEnabledGlobally(featuremgmt.FlagPluginsSkipHostEnvVars) &&
|
||||
cfg.PluginSettings[p.ID]["forward_host_env_vars"] != "true"
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user