-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove dependency from pkg/cwversion to pkg/acquisition (#3242)
* register built-in components without dependencies * package comment
- Loading branch information
Showing
7 changed files
with
104 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//go:build !no_cscli_setup | ||
package main | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/clisetup" | ||
"github.com/crowdsecurity/crowdsec/pkg/cwversion/component" | ||
"github.com/crowdsecurity/crowdsec/pkg/fflag" | ||
) | ||
|
||
func (cli *cliRoot) addSetup(cmd *cobra.Command) { | ||
if fflag.CscliSetup.IsEnabled() { | ||
cmd.AddCommand(clisetup.New(cli.cfg).NewCommand()) | ||
} | ||
|
||
component.Register("cscli_setup") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//go:build no_cscli_setup | ||
package main | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func (cli *cliRoot) addSetup(_ *cobra.Command) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package component | ||
|
||
// Package component provides functionality for managing the registration of | ||
// optional, compile-time components in the system. This is meant as a space | ||
// saving measure, separate from feature flags (package pkg/fflag) which are | ||
// only enabled/disabled at runtime. | ||
|
||
// Built is a map of all the known components, and whether they are built-in or not. | ||
// This is populated as soon as possible by the respective init() functions | ||
var Built = map[string]bool { | ||
"datasource_appsec": false, | ||
"datasource_cloudwatch": false, | ||
"datasource_docker": false, | ||
"datasource_file": false, | ||
"datasource_journalctl": false, | ||
"datasource_k8s-audit": false, | ||
"datasource_kafka": false, | ||
"datasource_kinesis": false, | ||
"datasource_loki": false, | ||
"datasource_s3": false, | ||
"datasource_syslog": false, | ||
"datasource_wineventlog":false, | ||
"cscli_setup": false, | ||
} | ||
|
||
func Register(name string) { | ||
if _, ok := Built[name]; !ok { | ||
// having a list of the disabled components is essential | ||
// to debug users' issues | ||
panic("cannot register unknown compile-time component: " + name) | ||
} | ||
|
||
Built[name] = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters