@@ -233,13 +233,21 @@ func AnalyzeSupportBundle(spec *troubleshootv1beta2.SupportBundleSpec, tmpDir st
233233 return analyzeResults , nil
234234}
235235
236- // the intention with these appends is to swap them out at a later date with more specific handlers for merging the spec fields
236+ // ConcatSpec the intention with these appends is to swap them out at a later date with more specific handlers for merging the spec fields
237237func ConcatSpec (target * troubleshootv1beta2.SupportBundle , source * troubleshootv1beta2.SupportBundle ) * troubleshootv1beta2.SupportBundle {
238- newBundle := target .DeepCopy ()
239- newBundle .Spec .Collectors = append (target .Spec .Collectors , source .Spec .Collectors ... )
240- newBundle .Spec .AfterCollection = append (target .Spec .AfterCollection , source .Spec .AfterCollection ... )
241- newBundle .Spec .HostCollectors = append (target .Spec .HostCollectors , source .Spec .HostCollectors ... )
242- newBundle .Spec .HostAnalyzers = append (target .Spec .HostAnalyzers , source .Spec .HostAnalyzers ... )
243- newBundle .Spec .Analyzers = append (target .Spec .Analyzers , source .Spec .Analyzers ... )
238+ if source == nil {
239+ return target
240+ }
241+ var newBundle * troubleshootv1beta2.SupportBundle
242+ if target == nil {
243+ newBundle = source
244+ } else {
245+ newBundle = target .DeepCopy ()
246+ newBundle .Spec .Collectors = append (target .Spec .Collectors , source .Spec .Collectors ... )
247+ newBundle .Spec .AfterCollection = append (target .Spec .AfterCollection , source .Spec .AfterCollection ... )
248+ newBundle .Spec .HostCollectors = append (target .Spec .HostCollectors , source .Spec .HostCollectors ... )
249+ newBundle .Spec .HostAnalyzers = append (target .Spec .HostAnalyzers , source .Spec .HostAnalyzers ... )
250+ newBundle .Spec .Analyzers = append (target .Spec .Analyzers , source .Spec .Analyzers ... )
251+ }
244252 return newBundle
245253}
0 commit comments