/
data.go
38 lines (30 loc) · 891 Bytes
/
data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package collect
import (
"bytes"
"context"
"path/filepath"
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)
type CollectData struct {
Collector *troubleshootv1beta2.Data
BundlePath string
Namespace string
ClientConfig *rest.Config
Client kubernetes.Interface
Context context.Context
RBACErrors
}
func (c *CollectData) Title() string {
return getCollectorName(c)
}
func (c *CollectData) IsExcluded() (bool, error) {
return isExcluded(c.Collector.Exclude)
}
func (c *CollectData) Collect(progressChan chan<- interface{}) (CollectorResult, error) {
bundlePath := filepath.Join(c.Collector.Name, c.Collector.CollectorName)
output := NewResult()
output.SaveResult(c.BundlePath, bundlePath, bytes.NewBuffer([]byte(c.Collector.Data)))
return output, nil
}