Skip to content

Commit 63510fc

Browse files
Moved ConcatSpec to supportbundle package and clean up dead code
Signed-off-by: Dan Jones <[email protected]>
1 parent 8bdb09f commit 63510fc

File tree

3 files changed

+26
-91
lines changed

3 files changed

+26
-91
lines changed

cmd/troubleshoot/cli/run.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,6 @@ func runTroubleshoot(v *viper.Viper, arg []string) error {
6868
})
6969
}
7070

71-
// collectorContent, err := supportbundle.LoadSupportBundleSpec(arg)
72-
// if err != nil {
73-
// return errors.Wrap(err, "failed to load collector spec")
74-
// }
75-
//
76-
// multidocs := strings.Split(string(collectorContent), "\n---\n")
77-
//
78-
// // we support both raw collector kinds and supportbundle kinds here
79-
// supportBundle, err := supportbundle.ParseSupportBundleFromDoc([]byte(multidocs[0]))
80-
// if err != nil {
81-
// return errors.Wrap(err, "failed to parse collector")
82-
// }
83-
8471
var mainBundle *troubleshootv1beta2.SupportBundle
8572

8673
troubleshootclientsetscheme.AddToScheme(scheme.Scheme)
@@ -101,7 +88,7 @@ func runTroubleshoot(v *viper.Viper, arg []string) error {
10188
if i == 0 {
10289
mainBundle = supportBundle
10390
} else {
104-
mainBundle.ConcatSpec(supportBundle)
91+
mainBundle = supportbundle.ConcatSpec(mainBundle, supportBundle)
10592
}
10693

10794
for i, additionalDoc := range multidocs {
@@ -135,25 +122,6 @@ func runTroubleshoot(v *viper.Viper, arg []string) error {
135122
}
136123
}
137124

138-
// for i, additionalDoc := range multidocs {
139-
// if i == 0 {
140-
// continue
141-
// }
142-
// additionalDoc, err := docrewrite.ConvertToV1Beta2([]byte(additionalDoc))
143-
// if err != nil {
144-
// return errors.Wrap(err, "failed to convert to v1beta2")
145-
// }
146-
// obj, _, err := decode(additionalDoc, nil, nil)
147-
// if err != nil {
148-
// return errors.Wrapf(err, "failed to parse additional doc %d", i)
149-
// }
150-
// multidocRedactors, ok := obj.(*troubleshootv1beta2.Redactor)
151-
// if !ok {
152-
// continue
153-
// }
154-
// additionalRedactors.Spec.Redactors = append(additionalRedactors.Spec.Redactors, multidocRedactors.Spec.Redactors...)
155-
// }
156-
157125
var collectorCB func(chan interface{}, string)
158126
progressChan := make(chan interface{}) // non-zero buffer can result in missed messages
159127
finishedCh := make(chan bool, 1)

pkg/apis/troubleshoot/v1beta2/supportbundle_interfaces.go

Lines changed: 0 additions & 58 deletions
This file was deleted.

pkg/supportbundle/supportbundle.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,28 @@ func AnalyzeSupportBundle(spec *troubleshootv1beta2.SupportBundleSpec, tmpDir st
226226
}
227227
return analyzeResults, nil
228228
}
229+
230+
231+
// the intention with these appends is to swap them out at a later date with more specific handlers for merging the spec fields
232+
func ConcatSpec(target *troubleshootv1beta2.SupportBundle, source *troubleshootv1beta2.SupportBundle) *troubleshootv1beta2.SupportBundle{
233+
234+
newBundle := target.DeepCopy()
235+
236+
for _, v := range source.Spec.Collectors {
237+
newBundle.Spec.Collectors = append(target.Spec.Collectors,v)
238+
}
239+
240+
for _, v := range source.Spec.AfterCollection {
241+
newBundle.Spec.AfterCollection = append(target.Spec.AfterCollection, v)
242+
}
243+
for _, v := range source.Spec.HostCollectors {
244+
newBundle.Spec.HostCollectors = append(target.Spec.HostCollectors, v)
245+
}
246+
for _, v := range source.Spec.HostAnalyzers {
247+
newBundle.Spec.HostAnalyzers = append(target.Spec.HostAnalyzers, v)
248+
}
249+
for _, v := range source.Spec.Analyzers {
250+
newBundle.Spec.Analyzers = append(target.Spec.Analyzers, v)
251+
}
252+
return newBundle
253+
}

0 commit comments

Comments
 (0)