(ctx context.Context, cConfig *csconfig.Config, hub *cwhub.Hub)
| 64 | } |
| 65 | |
| 66 | func LoadAcquisition(ctx context.Context, cConfig *csconfig.Config, hub *cwhub.Hub) ([]acquisitionTypes.DataSource, error) { |
| 67 | var datasources []acquisitionTypes.DataSource |
| 68 | |
| 69 | if flags.SingleFileType != "" && flags.OneShotDSN != "" { |
| 70 | flags.Labels["type"] = flags.SingleFileType |
| 71 | |
| 72 | ds, err := acquisition.LoadAcquisitionFromDSN(ctx, flags.OneShotDSN, flags.Labels, flags.Transform, hub) |
| 73 | if err != nil { |
| 74 | return nil, err |
| 75 | } |
| 76 | datasources = append(datasources, ds) |
| 77 | } else { |
| 78 | dss, err := acquisition.LoadAcquisitionFromFiles(ctx, cConfig.Crowdsec, cConfig.Prometheus, hub) |
| 79 | if err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | datasources = dss |
| 83 | } |
| 84 | |
| 85 | if len(datasources) == 0 { |
| 86 | return nil, errors.New("no datasource enabled") |
| 87 | } |
| 88 | |
| 89 | return datasources, nil |
| 90 | } |
| 91 | |
| 92 | // LoadConfig returns a configuration parsed from configuration file |
| 93 | func LoadConfig(configFile string, disableAgent bool, disableAPI bool, quiet bool) (*csconfig.Config, error) { |
no test coverage detected
searching dependent graphs…