Skip to content

Commit 8bdb09f

Browse files
Only accept one clusterResources collector
Signed-off-by: Dan Jones <[email protected]>
1 parent b20a8e5 commit 8bdb09f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/apis/troubleshoot/v1beta2/supportbundle_interfaces.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ func (s *SupportBundle) ConcatSpec(bundle *SupportBundle) {
2121

2222
func (s *SupportBundleSpec) MergeCollectors(spec *SupportBundleSpec) {
2323
for _,c := range spec.Collectors {
24+
// we want to move away from checking for specific collectors in favor of allowing collectors to expose their own merge method
25+
// 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'
2426

2527
if c.ClusterInfo != nil {
2628
// we only actually want one of these so skip if there's already one
2729
y := 0
28-
// we want to move away from checking for specific collectors in favor of allowing collectors to expose their own merge method
2930
for _,v := range s.Collectors{
3031
if v.ClusterInfo != nil {
3132
y = 1
@@ -37,6 +38,19 @@ func (s *SupportBundleSpec) MergeCollectors(spec *SupportBundleSpec) {
3738
continue
3839
}
3940

41+
if c.ClusterResources != nil {
42+
y := 0
43+
for _,v := range s.Collectors {
44+
if v.ClusterResources != nil {
45+
y = 1
46+
}
47+
}
48+
if y != 1 {
49+
s.Collectors = append(s.Collectors, c)
50+
}
51+
continue
52+
}
53+
4054
s.Collectors = append(s.Collectors, c)
4155

4256
}

0 commit comments

Comments
 (0)