Преглед на файлове

Merge branch 'acquisition-refactoring' of github.com:crowdsecurity/crowdsec into acquisition-refactoring

Sebastien Blot преди 4 години
родител
ревизия
971dd04793
променени са 2 файла, в които са добавени 12 реда и са изтрити 8 реда
  1. 1 0
      pkg/acquisition/acquisition.go
  2. 11 8
      pkg/acquisition/acquisition_test.go

+ 1 - 0
pkg/acquisition/acquisition.go

@@ -65,6 +65,7 @@ cat mode will return once source has been exhausted.
 type DataSource interface {
 type DataSource interface {
 	GetMetrics() []prometheus.Collector                    // Returns pointers to metrics that are managed by the module
 	GetMetrics() []prometheus.Collector                    // Returns pointers to metrics that are managed by the module
 	Configure([]byte, *log.Entry) error                    // Configure the datasource
 	Configure([]byte, *log.Entry) error                    // Configure the datasource
+	ConfigureByDSN(string, *log.Entry) error               // Configure the datasource
 	GetMode() string                                       // Get the mode (TAIL, CAT or SERVER)
 	GetMode() string                                       // Get the mode (TAIL, CAT or SERVER)
 	SupportedModes() []string                              // Returns the mode supported by the datasource
 	SupportedModes() []string                              // Returns the mode supported by the datasource
 	SupportedDSN() []string                                // Returns the list of supported URI schemes (file:// s3:// ...)
 	SupportedDSN() []string                                // Returns the list of supported URI schemes (file:// s3:// ...)

+ 11 - 8
pkg/acquisition/acquisition_test.go

@@ -42,6 +42,7 @@ func (f *MockSource) CanRun() error                                         { re
 func (f *MockSource) GetMetrics() []prometheus.Collector                    { return nil }
 func (f *MockSource) GetMetrics() []prometheus.Collector                    { return nil }
 func (f *MockSource) Dump() interface{}                                     { return f }
 func (f *MockSource) Dump() interface{}                                     { return f }
 func (f *MockSource) SupportedDSN() []string                                { return []string{"mock://"} }
 func (f *MockSource) SupportedDSN() []string                                { return []string{"mock://"} }
+func (f *MockSource) ConfigureByDSN(string, *log.Entry) error               { return fmt.Errorf("not supported") }
 
 
 //func (f *MockSource) New() DataSource                                       { return &MockSource{} }
 //func (f *MockSource) New() DataSource                                       { return &MockSource{} }
 
 
@@ -327,10 +328,11 @@ func (f *MockCat) OneShotAcquisition(out chan types.Event, tomb *tomb.Tomb) erro
 func (f *MockCat) LiveAcquisition(chan types.Event, *tomb.Tomb) error {
 func (f *MockCat) LiveAcquisition(chan types.Event, *tomb.Tomb) error {
 	return fmt.Errorf("can't run in tail")
 	return fmt.Errorf("can't run in tail")
 }
 }
-func (f *MockCat) CanRun() error                      { return nil }
-func (f *MockCat) GetMetrics() []prometheus.Collector { return nil }
-func (f *MockCat) Dump() interface{}                  { return f }
-func (f *MockCat) SupportedDSN() []string             { return []string{"mock://"} }
+func (f *MockCat) CanRun() error                           { return nil }
+func (f *MockCat) GetMetrics() []prometheus.Collector      { return nil }
+func (f *MockCat) Dump() interface{}                       { return f }
+func (f *MockCat) SupportedDSN() []string                  { return []string{"mock://"} }
+func (f *MockCat) ConfigureByDSN(string, *log.Entry) error { return fmt.Errorf("not supported") }
 
 
 //----
 //----
 
 
@@ -360,10 +362,11 @@ func (f *MockTail) LiveAcquisition(out chan types.Event, t *tomb.Tomb) error {
 		return nil
 		return nil
 	}
 	}
 }
 }
-func (f *MockTail) CanRun() error                      { return nil }
-func (f *MockTail) GetMetrics() []prometheus.Collector { return nil }
-func (f *MockTail) Dump() interface{}                  { return f }
-func (f *MockTail) SupportedDSN() []string             { return []string{"mock://"} }
+func (f *MockTail) CanRun() error                           { return nil }
+func (f *MockTail) GetMetrics() []prometheus.Collector      { return nil }
+func (f *MockTail) Dump() interface{}                       { return f }
+func (f *MockTail) SupportedDSN() []string                  { return []string{"mock://"} }
+func (f *MockTail) ConfigureByDSN(string, *log.Entry) error { return fmt.Errorf("not supported") }
 
 
 //func StartAcquisition(sources []DataSource, output chan types.Event, AcquisTomb *tomb.Tomb) error {
 //func StartAcquisition(sources []DataSource, output chan types.Event, AcquisTomb *tomb.Tomb) error {