Plugins: Forward feature toggles to plugins (#72995)
This commit is contained in:
@@ -31,7 +31,7 @@ func NewProvider(cfg *config.Cfg, license plugins.Licensing) *Service {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) Get(_ context.Context, p *plugins.Plugin) []string {
|
||||
func (s *Service) Get(ctx context.Context, p *plugins.Plugin) []string {
|
||||
hostEnv := []string{
|
||||
fmt.Sprintf("GF_VERSION=%s", s.cfg.BuildVersion),
|
||||
}
|
||||
@@ -56,6 +56,7 @@ func (s *Service) Get(_ context.Context, p *plugins.Plugin) []string {
|
||||
)
|
||||
}
|
||||
|
||||
hostEnv = append(hostEnv, s.featureToggleEnableVar(ctx)...)
|
||||
hostEnv = append(hostEnv, s.awsEnvVars()...)
|
||||
hostEnv = append(hostEnv, s.secureSocksProxyEnvVars()...)
|
||||
hostEnv = append(hostEnv, azsettings.WriteToEnvStr(s.cfg.Azure)...)
|
||||
@@ -84,6 +85,24 @@ func (s *Service) tracingEnvVars(plugin *plugins.Plugin) []string {
|
||||
return vars
|
||||
}
|
||||
|
||||
func (s *Service) featureToggleEnableVar(ctx context.Context) []string {
|
||||
var variables []string // an array is used for consistency and keep the logic simpler for no features case
|
||||
|
||||
if s.cfg.Features != nil {
|
||||
enabledFeatures := s.cfg.Features.GetEnabled(ctx)
|
||||
|
||||
if len(enabledFeatures) > 0 {
|
||||
features := make([]string, 0, len(enabledFeatures))
|
||||
for feat := range enabledFeatures {
|
||||
features = append(features, feat)
|
||||
}
|
||||
variables = append(variables, fmt.Sprintf("GF_INSTANCE_FEATURE_TOGGLES_ENABLE=%s", strings.Join(features, ",")))
|
||||
}
|
||||
}
|
||||
|
||||
return variables
|
||||
}
|
||||
|
||||
func (s *Service) awsEnvVars() []string {
|
||||
var variables []string
|
||||
if s.cfg.AWSAssumeRoleEnabled {
|
||||
|
||||
Reference in New Issue
Block a user