fflags: don't print deprecation warning if there is no message (papi) (#2666)

This commit is contained in:
mmetc 2023-12-18 09:35:57 +01:00 committed by GitHub
parent 08694adf1b
commit 822fcdacbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -5,7 +5,7 @@ var Crowdsec = FeatureRegister{EnvPrefix: "CROWDSEC_FEATURE_"}
var CscliSetup = &Feature{Name: "cscli_setup", Description: "Enable cscli setup command (service detection)"}
var DisableHttpRetryBackoff = &Feature{Name: "disable_http_retry_backoff", Description: "Disable http retry backoff"}
var ChunkedDecisionsStream = &Feature{Name: "chunked_decisions_stream", Description: "Enable chunked decisions stream"}
var PapiClient = &Feature{Name: "papi_client", Description: "Enable Polling API client", State: RetiredState}
var PapiClient = &Feature{Name: "papi_client", Description: "Enable Polling API client", State: DeprecatedState}
var Re2GrokSupport = &Feature{Name: "re2_grok_support", Description: "Enable RE2 support for GROK patterns"}
var Re2RegexpInfileSupport = &Feature{Name: "re2_regexp_in_file_support", Description: "Enable RE2 support for RegexpInFile expr helper"}
@ -14,22 +14,27 @@ func RegisterAllFeatures() error {
if err != nil {
return err
}
err = Crowdsec.RegisterFeature(DisableHttpRetryBackoff)
if err != nil {
return err
}
err = Crowdsec.RegisterFeature(ChunkedDecisionsStream)
if err != nil {
return err
}
err = Crowdsec.RegisterFeature(PapiClient)
if err != nil {
return err
}
err = Crowdsec.RegisterFeature(Re2GrokSupport)
if err != nil {
return err
}
err = Crowdsec.RegisterFeature(Re2RegexpInfileSupport)
if err != nil {
return err

View file

@ -18,10 +18,10 @@
// in feature.yaml. Features cannot be disabled in the file.
//
// A feature flag can be deprecated or retired. A deprecated feature flag is
// still accepted but a warning is logged. A retired feature flag is ignored
// and an error is logged.
// still accepted but a warning is logged (only if a deprecation message is provided).
// A retired feature flag is ignored and an error is logged.
//
// A specific deprecation message is used to inform the user of the behavior
// The message is inteded to inform the user of the behavior
// that has been decided when the flag is/was finally retired.
package fflag
@ -176,7 +176,9 @@ func (fr *FeatureRegister) SetFromEnv(logger *logrus.Logger) error {
logger.Errorf("Ignored envvar '%s': %s. %s", varName, err, feat.DeprecationMsg)
continue
case errors.Is(err, ErrFeatureDeprecated):
logger.Warningf("Envvar '%s': %s. %s", varName, err, feat.DeprecationMsg)
if feat.DeprecationMsg != "" {
logger.Warningf("Envvar '%s': %s. %s", varName, err, feat.DeprecationMsg)
}
case err != nil:
return err
}