|
1 | 1 | package fflag |
2 | 2 |
|
| 3 | +import "runtime" |
| 4 | + |
3 | 5 | var Crowdsec = FeatureRegister{EnvPrefix: "CROWDSEC_FEATURE_"} |
4 | 6 |
|
5 | 7 | var ( |
6 | 8 | DisableHttpRetryBackoff = &Feature{Name: "disable_http_retry_backoff", Description: "Disable http retry backoff"} |
7 | 9 | ChunkedDecisionsStream = &Feature{Name: "chunked_decisions_stream", Description: "Enable chunked decisions stream"} |
8 | 10 | PapiClient = &Feature{Name: "papi_client", Description: "Enable Polling API client", State: DeprecatedState} |
9 | | - Re2GrokSupport = &Feature{Name: "re2_grok_support", Description: "Enable RE2 support for GROK patterns"} |
10 | | - Re2RegexpInfileSupport = &Feature{Name: "re2_regexp_in_file_support", Description: "Enable RE2 support for RegexpInFile expr helper"} |
11 | | - PProfBlockProfile = &Feature{Name: "pprof_block_profile", Description: "Enable pprof block/mutex profiling. Do not use unless instructed by CrowdSec support"} |
| 11 | + // The state will be set to deprecated for linux only. |
| 12 | + Re2GrokSupport = &Feature{Name: "re2_grok_support", Description: "Enable RE2 support for GROK patterns"} |
| 13 | + // This one is only available on OS where RE2 support is enabled by default (linux only at the moment) |
| 14 | + Re2DisableGrokSupport = &Feature{Name: "re2_disable_grok_support", Description: "Disable RE2 support for GROK patterns (linux only)"} |
| 15 | + Re2RegexpInfileSupport = &Feature{Name: "re2_regexp_in_file_support", Description: "Enable RE2 support for RegexpInFile expr helper"} |
| 16 | + PProfBlockProfile = &Feature{Name: "pprof_block_profile", Description: "Enable pprof block/mutex profiling. Do not use unless instructed by CrowdSec support"} |
12 | 17 | ) |
13 | 18 |
|
| 19 | +//revive:disable:if-return |
14 | 20 | func RegisterAllFeatures() error { |
15 | | - err := Crowdsec.RegisterFeature(DisableHttpRetryBackoff) |
16 | | - if err != nil { |
| 21 | + if err := Crowdsec.RegisterFeature(DisableHttpRetryBackoff); err != nil { |
17 | 22 | return err |
18 | 23 | } |
19 | 24 |
|
20 | | - err = Crowdsec.RegisterFeature(ChunkedDecisionsStream) |
21 | | - if err != nil { |
| 25 | + if err := Crowdsec.RegisterFeature(ChunkedDecisionsStream); err != nil { |
22 | 26 | return err |
23 | 27 | } |
24 | 28 |
|
25 | | - err = Crowdsec.RegisterFeature(PapiClient) |
26 | | - if err != nil { |
| 29 | + if err := Crowdsec.RegisterFeature(PapiClient); err != nil { |
27 | 30 | return err |
28 | 31 | } |
29 | 32 |
|
30 | | - err = Crowdsec.RegisterFeature(Re2GrokSupport) |
31 | | - if err != nil { |
| 33 | + if err := Crowdsec.RegisterFeature(Re2RegexpInfileSupport); err != nil { |
32 | 34 | return err |
33 | 35 | } |
34 | 36 |
|
35 | | - err = Crowdsec.RegisterFeature(Re2RegexpInfileSupport) |
36 | | - if err != nil { |
| 37 | + if err := Crowdsec.RegisterFeature(PProfBlockProfile); err != nil { |
37 | 38 | return err |
38 | 39 | } |
39 | 40 |
|
40 | | - err = Crowdsec.RegisterFeature(PProfBlockProfile) |
41 | | - if err != nil { |
| 41 | + if runtime.GOOS == "linux" { |
| 42 | + // This cannot actually fail in a release, so the state will always be set |
| 43 | + if err := Crowdsec.RegisterFeature(Re2DisableGrokSupport); err != nil { |
| 44 | + return err |
| 45 | + } |
| 46 | + Re2GrokSupport.State = DeprecatedState |
| 47 | + } |
| 48 | + |
| 49 | + if err := Crowdsec.RegisterFeature(Re2GrokSupport); err != nil { |
42 | 50 | return err |
43 | 51 | } |
44 | 52 |
|
45 | 53 | return nil |
46 | 54 | } |
| 55 | + |
| 56 | +//revice:enable:if-return |
0 commit comments