mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
config.yaml: make config_dir and notification_dir optional (#3606)
Some checks are pending
Tests / sqlite (push) Waiting to run
Tests / mariadb (push) Waiting to run
Tests / mysql (push) Waiting to run
Tests / postgres (push) Waiting to run
Tests / hub (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Test Docker images / test_flavor (debian) (push) Waiting to run
Test Docker images / test_flavor (slim) (push) Waiting to run
Go tests (windows) / Build + tests (push) Waiting to run
Build / Build + tests (push) Waiting to run
(push-master) Publish latest Docker images / dev-alpine (push) Waiting to run
(push-master) Publish latest Docker images / dev-debian (push) Waiting to run
Some checks are pending
Tests / sqlite (push) Waiting to run
Tests / mariadb (push) Waiting to run
Tests / mysql (push) Waiting to run
Tests / postgres (push) Waiting to run
Tests / hub (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Test Docker images / test_flavor (debian) (push) Waiting to run
Test Docker images / test_flavor (slim) (push) Waiting to run
Go tests (windows) / Build + tests (push) Waiting to run
Build / Build + tests (push) Waiting to run
(push-master) Publish latest Docker images / dev-alpine (push) Waiting to run
(push-master) Publish latest Docker images / dev-debian (push) Waiting to run
This commit is contained in:
parent
ec553b34ad
commit
ce6018fbbf
7 changed files with 34 additions and 30 deletions
|
@ -19,10 +19,15 @@ type ConfigurationPaths struct {
|
|||
|
||||
func (c *Config) loadConfigurationPaths() error {
|
||||
var err error
|
||||
|
||||
if c.ConfigPaths == nil {
|
||||
return errors.New("no configuration paths provided")
|
||||
}
|
||||
|
||||
if c.ConfigPaths.ConfigDir == "" {
|
||||
c.ConfigPaths.ConfigDir = filepath.Dir(c.FilePath)
|
||||
}
|
||||
|
||||
if c.ConfigPaths.DataDir == "" {
|
||||
return errors.New("please provide a data directory with the 'data_dir' directive in the 'config_paths' section")
|
||||
}
|
||||
|
@ -35,6 +40,10 @@ func (c *Config) loadConfigurationPaths() error {
|
|||
c.ConfigPaths.HubIndexFile = filepath.Join(c.ConfigPaths.HubDir, ".index.json")
|
||||
}
|
||||
|
||||
if c.ConfigPaths.NotificationDir == "" {
|
||||
c.ConfigPaths.NotificationDir = filepath.Join(c.ConfigPaths.ConfigDir, "notifications")
|
||||
}
|
||||
|
||||
if c.ConfigPaths.PatternDir == "" {
|
||||
c.ConfigPaths.PatternDir = filepath.Join(c.ConfigPaths.ConfigDir, "patterns")
|
||||
}
|
||||
|
@ -53,6 +62,7 @@ func (c *Config) loadConfigurationPaths() error {
|
|||
if *k == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
*k, err = filepath.Abs(*k)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get absolute path of '%s': %w", *k, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue