load feature.yaml as soon as possible

This commit is contained in:
Marco Mariani 2023-01-17 10:40:19 +01:00 committed by mmetc
parent f25fdecc3f
commit 2e91a82aa7
4 changed files with 11 additions and 8 deletions

View file

@ -66,10 +66,6 @@ func initConfig() {
csConfig = csconfig.NewDefaultConfig()
}
if err := csconfig.LoadFeatureFlagsFile(csConfig, log.StandardLogger()); err != nil {
log.Fatal(err)
}
// recap of the enabled feature flags, because logging
// was not enabled when we set them from envvars
if fflist := csconfig.ListFeatureFlags(); fflist != "" {

View file

@ -260,10 +260,6 @@ func LoadConfig(cConfig *csconfig.Config) error {
return err
}
if err := csconfig.LoadFeatureFlagsFile(cConfig, log.StandardLogger()); err != nil {
return err
}
// recap of the enabled feature flags, because logging
// was not enabled when we set them from envvars
if fflist := csconfig.ListFeatureFlags(); fflist != "" {

View file

@ -45,6 +45,10 @@ func (c *Config) LoadCrowdsec() error {
return err
}
if err = LoadFeatureFlagsFile(c, log.StandardLogger()); err != nil {
return err
}
if c.Crowdsec == nil {
log.Warning("crowdsec agent is disabled")
c.DisableAgent = true

View file

@ -1,5 +1,9 @@
package csconfig
import (
log "github.com/sirupsen/logrus"
)
/*cscli specific config, such as hub directory*/
type CscliCfg struct {
Output string `yaml:"output,omitempty"`
@ -22,6 +26,9 @@ func (c *Config) LoadCSCLI() error {
if err := c.LoadConfigurationPaths(); err != nil {
return err
}
if err := LoadFeatureFlagsFile(c, log.StandardLogger()); err != nil {
return err
}
c.Cscli.ConfigDir = c.ConfigPaths.ConfigDir
c.Cscli.DataDir = c.ConfigPaths.DataDir
c.Cscli.HubDir = c.ConfigPaths.HubDir