Only accept one clusterResources collector

Signed-off-by: Dan Jones <danj@replicated.com>
This commit is contained in:
Dan Jones
2022-08-26 11:36:44 +01:00
parent b20a8e5321
commit 8bdb09ff7d

View File

@@ -21,11 +21,12 @@ func (s *SupportBundle) ConcatSpec(bundle *SupportBundle) {
func (s *SupportBundleSpec) MergeCollectors(spec *SupportBundleSpec) {
for _,c := range spec.Collectors {
// we want to move away from checking for specific collectors in favor of allowing collectors to expose their own merge method
// 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'
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
@@ -37,6 +38,19 @@ func (s *SupportBundleSpec) MergeCollectors(spec *SupportBundleSpec) {
continue
}
if c.ClusterResources != nil {
y := 0
for _,v := range s.Collectors {
if v.ClusterResources != nil {
y = 1
}
}
if y != 1 {
s.Collectors = append(s.Collectors, c)
}
continue
}
s.Collectors = append(s.Collectors, c)
}