diff --git a/cmd/crowdsec-cli/clihub/hub.go b/cmd/crowdsec-cli/clihub/hub.go index 9571b3d866d..36e851d1b74 100644 --- a/cmd/crowdsec-cli/clihub/hub.go +++ b/cmd/crowdsec-cli/clihub/hub.go @@ -177,11 +177,15 @@ func (cli *cliHub) upgrade(ctx context.Context, yes bool, dryRun bool, force boo for _, itemType := range cwhub.ItemTypes { for _, item := range hub.GetInstalledByType(itemType, true) { - plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, force)) + if err := plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, force)); err != nil { + return err + } } } - plan.AddCommand(hubops.NewDataRefreshCommand(force)) + if err := plan.AddCommand(hubops.NewDataRefreshCommand(force)); err != nil { + return err + } verbose := (cfg.Cscli.Output == "raw") diff --git a/pkg/setup/install.go b/pkg/setup/install.go index 42634672912..3d1540f23be 100644 --- a/pkg/setup/install.go +++ b/pkg/setup/install.go @@ -71,10 +71,14 @@ func InstallHubItems(ctx context.Context, hub *cwhub.Hub, contentProvider cwhub. return fmt.Errorf("collection %s not found", collection) } - plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction)) + if err := plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction)); err != nil { + return err + } if !downloadOnly { - plan.AddCommand(hubops.NewEnableCommand(item, forceAction)) + if err := plan.AddCommand(hubops.NewEnableCommand(item, forceAction)); err != nil { + return err + } } } @@ -84,10 +88,14 @@ func InstallHubItems(ctx context.Context, hub *cwhub.Hub, contentProvider cwhub. return fmt.Errorf("parser %s not found", parser) } - plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction)) + if err := plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction)); err != nil { + return err + } if !downloadOnly { - plan.AddCommand(hubops.NewEnableCommand(item, forceAction)) + if err := plan.AddCommand(hubops.NewEnableCommand(item, forceAction)); err != nil { + return err + } } } @@ -97,10 +105,14 @@ func InstallHubItems(ctx context.Context, hub *cwhub.Hub, contentProvider cwhub. return fmt.Errorf("scenario %s not found", scenario) } - plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction)) + if err := plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction)); err != nil { + return err + } if !downloadOnly { - plan.AddCommand(hubops.NewEnableCommand(item, forceAction)) + if err := plan.AddCommand(hubops.NewEnableCommand(item, forceAction)); err != nil { + return err + } } } @@ -110,10 +122,14 @@ func InstallHubItems(ctx context.Context, hub *cwhub.Hub, contentProvider cwhub. return fmt.Errorf("postoverflow %s not found", postoverflow) } - plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction)) + if err := plan.AddCommand(hubops.NewDownloadCommand(item, contentProvider, forceAction)); err != nil { + return err + } if !downloadOnly { - plan.AddCommand(hubops.NewEnableCommand(item, forceAction)) + if err := plan.AddCommand(hubops.NewEnableCommand(item, forceAction)); err != nil { + return err + } } } }