mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 20:36:12 +02:00
pkg/cwhub - refact Downloader (#3382)
* pkg/cwhub - refact Downloader * single method interfaces * lint
This commit is contained in:
parent
fc17c0c613
commit
78f4b85311
31 changed files with 307 additions and 273 deletions
|
@ -48,7 +48,7 @@ func decodeSetup(input []byte, fancyErrors bool) (Setup, error) {
|
|||
}
|
||||
|
||||
// InstallHubItems installs the objects recommended in a setup file.
|
||||
func InstallHubItems(ctx context.Context, hub *cwhub.Hub, input []byte, yes, dryRun, verbose bool) error {
|
||||
func InstallHubItems(ctx context.Context, hub *cwhub.Hub, contentProvider cwhub.ContentProvider, input []byte, yes, dryRun, verbose bool) error {
|
||||
setupEnvelope, err := decodeSetup(input, false)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -71,7 +71,8 @@ func InstallHubItems(ctx context.Context, hub *cwhub.Hub, input []byte, yes, dry
|
|||
return fmt.Errorf("collection %s not found", collection)
|
||||
}
|
||||
|
||||
plan.AddCommand(hubops.NewDownloadCommand(item, forceAction))
|
||||
plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction))
|
||||
|
||||
if !downloadOnly {
|
||||
plan.AddCommand(hubops.NewEnableCommand(item, forceAction))
|
||||
}
|
||||
|
@ -83,7 +84,8 @@ func InstallHubItems(ctx context.Context, hub *cwhub.Hub, input []byte, yes, dry
|
|||
return fmt.Errorf("parser %s not found", parser)
|
||||
}
|
||||
|
||||
plan.AddCommand(hubops.NewDownloadCommand(item, forceAction))
|
||||
plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction))
|
||||
|
||||
if !downloadOnly {
|
||||
plan.AddCommand(hubops.NewEnableCommand(item, forceAction))
|
||||
}
|
||||
|
@ -95,7 +97,8 @@ func InstallHubItems(ctx context.Context, hub *cwhub.Hub, input []byte, yes, dry
|
|||
return fmt.Errorf("scenario %s not found", scenario)
|
||||
}
|
||||
|
||||
plan.AddCommand(hubops.NewDownloadCommand(item, forceAction))
|
||||
plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction))
|
||||
|
||||
if !downloadOnly {
|
||||
plan.AddCommand(hubops.NewEnableCommand(item, forceAction))
|
||||
}
|
||||
|
@ -107,7 +110,8 @@ func InstallHubItems(ctx context.Context, hub *cwhub.Hub, input []byte, yes, dry
|
|||
return fmt.Errorf("postoverflow %s not found", postoverflow)
|
||||
}
|
||||
|
||||
plan.AddCommand(hubops.NewDownloadCommand(item, forceAction))
|
||||
plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction))
|
||||
|
||||
if !downloadOnly {
|
||||
plan.AddCommand(hubops.NewEnableCommand(item, forceAction))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue