Skip to content

Commit

Permalink
Remove redundant loops
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Jones <danj@replicated.com>
  • Loading branch information
danj-replicated committed Sep 7, 2022
1 parent b6f8ac2 commit b5a56e5
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions pkg/supportbundle/supportbundle.go
Expand Up @@ -230,20 +230,10 @@ func AnalyzeSupportBundle(spec *troubleshootv1beta2.SupportBundleSpec, tmpDir st
// the intention with these appends is to swap them out at a later date with more specific handlers for merging the spec fields
func ConcatSpec(target *troubleshootv1beta2.SupportBundle, source *troubleshootv1beta2.SupportBundle) *troubleshootv1beta2.SupportBundle {
newBundle := target.DeepCopy()
for _, v := range source.Spec.Collectors {
newBundle.Spec.Collectors = append(target.Spec.Collectors, v)
}
for _, v := range source.Spec.AfterCollection {
newBundle.Spec.AfterCollection = append(target.Spec.AfterCollection, v)
}
for _, v := range source.Spec.HostCollectors {
newBundle.Spec.HostCollectors = append(target.Spec.HostCollectors, v)
}
for _, v := range source.Spec.HostAnalyzers {
newBundle.Spec.HostAnalyzers = append(target.Spec.HostAnalyzers, v)
}
for _, v := range source.Spec.Analyzers {
newBundle.Spec.Analyzers = append(target.Spec.Analyzers, v)
}
newBundle.Spec.Collectors = append(target.Spec.Collectors, source.Spec.Collectors...)
newBundle.Spec.AfterCollection = append(target.Spec.AfterCollection, source.Spec.AfterCollection...)
newBundle.Spec.HostCollectors = append(target.Spec.HostCollectors, source.Spec.HostCollectors...)
newBundle.Spec.HostAnalyzers = append(target.Spec.HostAnalyzers, source.Spec.HostAnalyzers...)
newBundle.Spec.Analyzers = append(target.Spec.Analyzers, source.Spec.Analyzers...)
return newBundle
}

0 comments on commit b5a56e5

Please sign in to comment.