Skip to content

Commit

Permalink
Only accept one clusterResources collector
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 Aug 26, 2022
1 parent b20a8e5 commit 8bdb09f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/apis/troubleshoot/v1beta2/supportbundle_interfaces.go
Expand Up @@ -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
Expand All @@ -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)

}
Expand Down

0 comments on commit 8bdb09f

Please sign in to comment.