Skip to content

Commit

Permalink
Better error check for no collectors
Browse files Browse the repository at this point in the history
  • Loading branch information
banjoh committed Sep 25, 2023
1 parent d9269e2 commit 0fbca57
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cmd/troubleshoot/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ func runTroubleshoot(v *viper.Viper, args []string) error {
return nil
}

// Check if we have any collectors to run in the support bundle specs
if len(mainBundle.Spec.Collectors) == 0 && len(mainBundle.Spec.HostCollectors) == 0 {
return errors.New("no collectors specified to run")
}

interactive := v.GetBool("interactive") && isatty.IsTerminal(os.Stdout.Fd())

if interactive {
Expand Down Expand Up @@ -273,6 +268,14 @@ func loadSpecs(ctx context.Context, args []string, client kubernetes.Interface)
kinds.Add(moreKinds)
}

// Check if we have any collectors to run in the troubleshoot specs
// TODO: Do we use the RemoteCollectors anymore?
if len(kinds.CollectorsV1Beta2) == 0 &&
len(kinds.HostCollectorsV1Beta2) == 0 &&
len(kinds.SupportBundlesV1Beta2) == 0 {
return nil, nil, errors.New("no collectors specified to run")
}

// Merge specs
// We need to add the default type information to the support bundle spec
// since by default these fields would be empty
Expand Down

0 comments on commit 0fbca57

Please sign in to comment.