Skip to content

Commit 04c7a18

Browse files
Fix Progress Callback for Support Bundle Collection (#781)
fix progress callback for support bundle and revert collector title changes
1 parent 9b37b98 commit 04c7a18

21 files changed

+102
-20
lines changed

pkg/collect/cluster_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type CollectClusterInfo struct {
2626
}
2727

2828
func (c *CollectClusterInfo) Title() string {
29-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Cluster Info")
29+
return getCollectorName(c)
3030
}
3131

3232
func (c *CollectClusterInfo) IsExcluded() (bool, error) {

pkg/collect/cluster_resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type CollectClusterResources struct {
4343
}
4444

4545
func (c *CollectClusterResources) Title() string {
46-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Cluster Resources")
46+
return getCollectorName(c)
4747
}
4848

4949
func (c *CollectClusterResources) IsExcluded() (bool, error) {

pkg/collect/collectd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type CollectCollectd struct {
1919
}
2020

2121
func (c *CollectCollectd) Title() string {
22-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "CollectD")
22+
return getCollectorName(c)
2323
}
2424

2525
func (c *CollectCollectd) IsExcluded() (bool, error) {

pkg/collect/collector.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package collect
22

33
import (
44
"context"
5+
"fmt"
56
"strconv"
7+
"strings"
68
"time"
79

810
"github.com/pkg/errors"
@@ -107,3 +109,83 @@ func collectorTitleOrDefault(meta troubleshootv1beta2.CollectorMeta, defaultTitl
107109
}
108110
return defaultTitle
109111
}
112+
113+
func getCollectorName(c interface{}) string {
114+
var collector, name, selector string
115+
116+
switch v := c.(type) {
117+
case *CollectClusterInfo:
118+
collector = "cluster-info"
119+
case *CollectClusterResources:
120+
collector = "cluster-resources"
121+
case *CollectSecret:
122+
collector = "secret"
123+
name = v.Collector.CollectorName
124+
selector = strings.Join(v.Collector.Selector, ",")
125+
case *CollectConfigMap:
126+
collector = "configmap"
127+
name = v.Collector.CollectorName
128+
selector = strings.Join(v.Collector.Selector, ",")
129+
case *CollectLogs:
130+
collector = "logs"
131+
name = v.Collector.CollectorName
132+
selector = strings.Join(v.Collector.Selector, ",")
133+
case *CollectRun:
134+
collector = "run"
135+
name = v.Collector.CollectorName
136+
case *CollectRunPod:
137+
collector = "run-pod"
138+
name = v.Collector.CollectorName
139+
case *CollectExec:
140+
collector = "exec"
141+
name = v.Collector.CollectorName
142+
selector = strings.Join(v.Collector.Selector, ",")
143+
case *CollectData:
144+
collector = "data"
145+
name = v.Collector.CollectorName
146+
case *CollectCopy:
147+
collector = "copy"
148+
name = v.Collector.CollectorName
149+
selector = strings.Join(v.Collector.Selector, ",")
150+
case *CollectCopyFromHost:
151+
collector = "copy-from-host"
152+
name = v.Collector.CollectorName
153+
case *CollectHTTP:
154+
collector = "http"
155+
name = v.Collector.CollectorName
156+
case *CollectPostgres:
157+
collector = "postgres"
158+
name = v.Collector.CollectorName
159+
case *CollectMysql:
160+
collector = "mysql"
161+
name = v.Collector.CollectorName
162+
case *CollectRedis:
163+
collector = "redis"
164+
name = v.Collector.CollectorName
165+
case *CollectCollectd:
166+
collector = "collectd"
167+
name = v.Collector.CollectorName
168+
case *CollectCeph:
169+
collector = "ceph"
170+
name = v.Collector.CollectorName
171+
case *CollectLonghorn:
172+
collector = "longhorn"
173+
name = v.Collector.CollectorName
174+
case *CollectRegistry:
175+
collector = "registry-images"
176+
name = v.Collector.CollectorName
177+
case *CollectSysctl:
178+
collector = "sysctl"
179+
name = v.Collector.Name
180+
default:
181+
collector = "<none>"
182+
}
183+
184+
if name != "" {
185+
return fmt.Sprintf("%s/%s", collector, name)
186+
}
187+
if selector != "" {
188+
return fmt.Sprintf("%s/%s", collector, selector)
189+
}
190+
return collector
191+
}

pkg/collect/configmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type CollectConfigMap struct {
3838
}
3939

4040
func (c *CollectConfigMap) Title() string {
41-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "ConfigMap")
41+
return getCollectorName(c)
4242
}
4343

4444
func (c *CollectConfigMap) IsExcluded() (bool, error) {

pkg/collect/copy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type CollectCopy struct {
3131
}
3232

3333
func (c *CollectCopy) Title() string {
34-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Copy")
34+
return getCollectorName(c)
3535
}
3636

3737
func (c *CollectCopy) IsExcluded() (bool, error) {

pkg/collect/copy_from_host.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type CollectCopyFromHost struct {
3737
}
3838

3939
func (c *CollectCopyFromHost) Title() string {
40-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Copy from Host")
40+
return getCollectorName(c)
4141
}
4242

4343
func (c *CollectCopyFromHost) IsExcluded() (bool, error) {

pkg/collect/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type CollectData struct {
2121
}
2222

2323
func (c *CollectData) Title() string {
24-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Data")
24+
return getCollectorName(c)
2525
}
2626

2727
func (c *CollectData) IsExcluded() (bool, error) {

pkg/collect/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type CollectExec struct {
2727
}
2828

2929
func (c *CollectExec) Title() string {
30-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Exec")
30+
return getCollectorName(c)
3131
}
3232

3333
func (c *CollectExec) IsExcluded() (bool, error) {

pkg/collect/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type CollectHTTP struct {
4545
}
4646

4747
func (c *CollectHTTP) Title() string {
48-
return collectorTitleOrDefault(c.Collector.CollectorMeta, "HTTP")
48+
return getCollectorName(c)
4949
}
5050

5151
func (c *CollectHTTP) IsExcluded() (bool, error) {

0 commit comments

Comments
 (0)