From 822fcdacbb34a8983ab5a3c84157c5c058613d53 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Mon, 18 Dec 2023 09:35:57 +0100 Subject: [PATCH] fflags: don't print deprecation warning if there is no message (papi) (#2666) --- pkg/fflag/crowdsec.go | 7 ++++++- pkg/fflag/features.go | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/fflag/crowdsec.go b/pkg/fflag/crowdsec.go index 814bd02f3..d42d6a05e 100644 --- a/pkg/fflag/crowdsec.go +++ b/pkg/fflag/crowdsec.go @@ -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 diff --git a/pkg/fflag/features.go b/pkg/fflag/features.go index b3c0a8bfe..3a106984a 100644 --- a/pkg/fflag/features.go +++ b/pkg/fflag/features.go @@ -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 }