Skip to content

Commit

Permalink
more errcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Dec 31, 2024
1 parent a79d15d commit 7c79f43
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
8 changes: 6 additions & 2 deletions cmd/crowdsec-cli/clihub/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Check warning on line 182 in cmd/crowdsec-cli/clihub/hub.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/clihub/hub.go#L181-L182

Added lines #L181 - L182 were not covered by tests
}
}

plan.AddCommand(hubops.NewDataRefreshCommand(force))
if err := plan.AddCommand(hubops.NewDataRefreshCommand(force)); err != nil {
return err
}

Check warning on line 188 in cmd/crowdsec-cli/clihub/hub.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/clihub/hub.go#L187-L188

Added lines #L187 - L188 were not covered by tests

verbose := (cfg.Cscli.Output == "raw")

Expand Down
32 changes: 24 additions & 8 deletions pkg/setup/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Check warning on line 76 in pkg/setup/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/setup/install.go#L75-L76

Added lines #L75 - L76 were not covered by tests

if !downloadOnly {
plan.AddCommand(hubops.NewEnableCommand(item, forceAction))
if err := plan.AddCommand(hubops.NewEnableCommand(item, forceAction)); err != nil {
return err
}

Check warning on line 81 in pkg/setup/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/setup/install.go#L80-L81

Added lines #L80 - L81 were not covered by tests
}
}

Expand All @@ -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
}

Check warning on line 93 in pkg/setup/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/setup/install.go#L92-L93

Added lines #L92 - L93 were not covered by tests

if !downloadOnly {
plan.AddCommand(hubops.NewEnableCommand(item, forceAction))
if err := plan.AddCommand(hubops.NewEnableCommand(item, forceAction)); err != nil {
return err
}

Check warning on line 98 in pkg/setup/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/setup/install.go#L97-L98

Added lines #L97 - L98 were not covered by tests
}
}

Expand All @@ -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
}

Check warning on line 110 in pkg/setup/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/setup/install.go#L109-L110

Added lines #L109 - L110 were not covered by tests

if !downloadOnly {
plan.AddCommand(hubops.NewEnableCommand(item, forceAction))
if err := plan.AddCommand(hubops.NewEnableCommand(item, forceAction)); err != nil {
return err
}

Check warning on line 115 in pkg/setup/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/setup/install.go#L114-L115

Added lines #L114 - L115 were not covered by tests
}
}

Expand All @@ -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
}

Check warning on line 127 in pkg/setup/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/setup/install.go#L126-L127

Added lines #L126 - L127 were not covered by tests

if !downloadOnly {
plan.AddCommand(hubops.NewEnableCommand(item, forceAction))
if err := plan.AddCommand(hubops.NewEnableCommand(item, forceAction)); err != nil {
return err
}

Check warning on line 132 in pkg/setup/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/setup/install.go#L131-L132

Added lines #L131 - L132 were not covered by tests
}
}
}
Expand Down

0 comments on commit 7c79f43

Please sign in to comment.