Add example breakout point for collector merging
package v1beta2
+// the intention with these appends is to swap them out at a later date with more specific handlers for merging the spec fields
func (s *SupportBundle) ConcatSpec(bundle *SupportBundle) {
- for _, v := range bundle.Spec.Collectors {
- s.Spec.Collectors = append(s.Spec.Collectors, v)
- }
+
+ s.Spec.MergeCollectors(&bundle.Spec)
+
for _, v := range bundle.Spec.AfterCollection {
s.Spec.AfterCollection = append(s.Spec.AfterCollection, v)
}
@@ -17,3 +18,27 @@ func (s *SupportBundle) ConcatSpec(bundle *SupportBundle) {
s.Spec.Analyzers = append(s.Spec.Analyzers, v)
}
}
+
+func (s *SupportBundleSpec) MergeCollectors(spec *SupportBundleSpec) {
+ for _,c := range spec.Collectors {
+
+ 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
+ }
+ }
+ if y != 1 {
+ s.Collectors = append(s.Collectors, c)
+ }
+ continue
+ }
+
+ s.Collectors = append(s.Collectors, c)
+
+ }
+}
+
