fflags: don't print deprecation warning if there is no message (papi) (#2666)
This commit is contained in:
parent
08694adf1b
commit
822fcdacbb
2 changed files with 12 additions and 5 deletions
|
@ -5,7 +5,7 @@ var Crowdsec = FeatureRegister{EnvPrefix: "CROWDSEC_FEATURE_"}
|
||||||
var CscliSetup = &Feature{Name: "cscli_setup", Description: "Enable cscli setup command (service detection)"}
|
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 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 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 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"}
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = Crowdsec.RegisterFeature(DisableHttpRetryBackoff)
|
err = Crowdsec.RegisterFeature(DisableHttpRetryBackoff)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = Crowdsec.RegisterFeature(ChunkedDecisionsStream)
|
err = Crowdsec.RegisterFeature(ChunkedDecisionsStream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = Crowdsec.RegisterFeature(PapiClient)
|
err = Crowdsec.RegisterFeature(PapiClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = Crowdsec.RegisterFeature(Re2GrokSupport)
|
err = Crowdsec.RegisterFeature(Re2GrokSupport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = Crowdsec.RegisterFeature(Re2RegexpInfileSupport)
|
err = Crowdsec.RegisterFeature(Re2RegexpInfileSupport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
// in feature.yaml. Features cannot be disabled in the file.
|
// in feature.yaml. Features cannot be disabled in the file.
|
||||||
//
|
//
|
||||||
// A feature flag can be deprecated or retired. A deprecated feature flag is
|
// 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
|
// still accepted but a warning is logged (only if a deprecation message is provided).
|
||||||
// and an error is logged.
|
// 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.
|
// that has been decided when the flag is/was finally retired.
|
||||||
|
|
||||||
package fflag
|
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)
|
logger.Errorf("Ignored envvar '%s': %s. %s", varName, err, feat.DeprecationMsg)
|
||||||
continue
|
continue
|
||||||
case errors.Is(err, ErrFeatureDeprecated):
|
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:
|
case err != nil:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue