From 51c10e1127bba260b661099c3412d7baa15cfec2 Mon Sep 17 00:00:00 2001 From: Michele Costa Date: Wed, 30 Aug 2023 16:26:16 +0100 Subject: [PATCH] Don't short circuit collector names and change collector selector defualt names - Change all to defaults and include opt in collectors for All --- pkg/cmd/collect.go | 2 +- pkg/runner/collector_selector.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/collect.go b/pkg/cmd/collect.go index bca3c008..96f45d95 100644 --- a/pkg/cmd/collect.go +++ b/pkg/cmd/collect.go @@ -100,7 +100,7 @@ func init() { //nolint:funlen // Allow this to get a little long "interval at which to emit the device info summary to the targeted output.", ) defaultCollectorNames := make([]string, 0) - defaultCollectorNames = append(defaultCollectorNames, runner.All) + defaultCollectorNames = append(defaultCollectorNames, runner.Default) collectCmd.Flags().StringSliceVarP( &collectorNames, "collector", diff --git a/pkg/runner/collector_selector.go b/pkg/runner/collector_selector.go index e853d24c..c3603def 100644 --- a/pkg/runner/collector_selector.go +++ b/pkg/runner/collector_selector.go @@ -14,6 +14,7 @@ var ( OptionalCollectorNames []string RequiredCollectorNames []string OptInCollectorNames []string + Default string = "defaults" All string = "all" ) @@ -53,8 +54,9 @@ func GetCollectorsToRun(selectedCollectors []string) []string { switch { case strings.EqualFold(name, "all"): collectorNames = append(collectorNames, OptionalCollectorNames...) - collectorNames = removeDuplicates(collectorNames) - return collectorNames + collectorNames = append(collectorNames, OptInCollectorNames...) + case strings.EqualFold(name, "defaults"): + collectorNames = append(collectorNames, OptionalCollectorNames...) case isIn(name, collectorNames): continue case isIn(name, OptionalCollectorNames): @@ -65,5 +67,6 @@ func GetCollectorsToRun(selectedCollectors []string) []string { log.Errorf("Unknown collector %s. Ignored", name) } } + collectorNames = removeDuplicates(collectorNames) return collectorNames }