From 8bdb09ff7dd74c4ef98766633dbd60301f8fc985 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Fri, 26 Aug 2022 11:36:44 +0100 Subject: [PATCH] Only accept one clusterResources collector Signed-off-by: Dan Jones --- .../v1beta2/supportbundle_interfaces.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/apis/troubleshoot/v1beta2/supportbundle_interfaces.go b/pkg/apis/troubleshoot/v1beta2/supportbundle_interfaces.go index b852a6eb..74f3619a 100644 --- a/pkg/apis/troubleshoot/v1beta2/supportbundle_interfaces.go +++ b/pkg/apis/troubleshoot/v1beta2/supportbundle_interfaces.go @@ -21,11 +21,12 @@ func (s *SupportBundle) ConcatSpec(bundle *SupportBundle) { func (s *SupportBundleSpec) MergeCollectors(spec *SupportBundleSpec) { for _,c := range spec.Collectors { + // we want to move away from checking for specific collectors in favor of allowing collectors to expose their own merge method + // ideally we'd just want to be able to call something like c.Merge(spec) here and have the collector's own merge method work out what to do' if c.ClusterInfo != nil { // we only actually want one of these so skip if there's already one y := 0 - // we want to move away from checking for specific collectors in favor of allowing collectors to expose their own merge method for _,v := range s.Collectors{ if v.ClusterInfo != nil { y = 1 @@ -37,6 +38,19 @@ func (s *SupportBundleSpec) MergeCollectors(spec *SupportBundleSpec) { continue } + if c.ClusterResources != nil { + y := 0 + for _,v := range s.Collectors { + if v.ClusterResources != nil { + y = 1 + } + } + if y != 1 { + s.Collectors = append(s.Collectors, c) + } + continue + } + s.Collectors = append(s.Collectors, c) }