💄 fix lint

This commit is contained in:
Max Lerebourg
2022-12-05 08:17:17 +01:00
parent 22e3febb45
commit 8f5b7bb9af
+6 -6
View File
@@ -20,8 +20,8 @@ const (
StreamMode = "stream" StreamMode = "stream"
LiveMode = "live" LiveMode = "live"
NoneMode = "none" NoneMode = "none"
Https = "https" HTTPS = "https"
Http = "http" HTTP = "http"
) )
// Config the plugin configuration. // Config the plugin configuration.
@@ -64,7 +64,7 @@ func New() *Config {
Enabled: false, Enabled: false,
LogLevel: "INFO", LogLevel: "INFO",
CrowdsecMode: LiveMode, CrowdsecMode: LiveMode,
CrowdsecLapiScheme: Http, CrowdsecLapiScheme: HTTP,
CrowdsecLapiHost: "crowdsec:8080", CrowdsecLapiHost: "crowdsec:8080",
CrowdsecLapiKey: "", CrowdsecLapiKey: "",
CrowdsecLapiTLSInsecureVerify: false, CrowdsecLapiTLSInsecureVerify: false,
@@ -145,7 +145,7 @@ func ValidateParams(config *Config) error {
} }
// Case https to contact Crowdsec LAPI and certificate must be provided // Case https to contact Crowdsec LAPI and certificate must be provided
if config.CrowdsecLapiScheme == Https && !config.CrowdsecLapiTLSInsecureVerify { if config.CrowdsecLapiScheme == HTTPS && !config.CrowdsecLapiTLSInsecureVerify {
err = validateParamsTLS(config) err = validateParamsTLS(config)
if err != nil { if err != nil {
return err return err
@@ -205,7 +205,7 @@ func validateParamsRequired(config *Config) error {
if !contains([]string{NoneMode, LiveMode, StreamMode}, config.CrowdsecMode) { if !contains([]string{NoneMode, LiveMode, StreamMode}, config.CrowdsecMode) {
return fmt.Errorf("CrowdsecMode: must be one of 'none', 'live' or 'stream'") return fmt.Errorf("CrowdsecMode: must be one of 'none', 'live' or 'stream'")
} }
if !contains([]string{Http, Https}, config.CrowdsecLapiScheme) { if !contains([]string{HTTP, HTTPS}, config.CrowdsecLapiScheme) {
return fmt.Errorf("CrowdsecLapiScheme: must be one of 'http' or 'https'") return fmt.Errorf("CrowdsecLapiScheme: must be one of 'http' or 'https'")
} }
return nil return nil
@@ -216,7 +216,7 @@ func GetTLSConfigCrowdsec(config *Config) (*tls.Config, error) {
tlsConfig := new(tls.Config) tlsConfig := new(tls.Config)
tlsConfig.RootCAs = x509.NewCertPool() tlsConfig.RootCAs = x509.NewCertPool()
//nolint:gocritic //nolint:gocritic
if config.CrowdsecLapiScheme != Https { if config.CrowdsecLapiScheme != HTTPS {
logger.Debug("getTLSConfigCrowdsec:CrowdsecLapiScheme not https") logger.Debug("getTLSConfigCrowdsec:CrowdsecLapiScheme not https")
return tlsConfig, nil return tlsConfig, nil
} else if config.CrowdsecLapiTLSInsecureVerify { } else if config.CrowdsecLapiTLSInsecureVerify {