Files
troubleshoot/pkg/collect/data.go
Diamon Wiggins c7b84ad1e5 Refactor in-clusters collectors to use struct per collector (#670)
refactor in-clusters collectors to use struct per collector
2022-10-03 13:53:05 -04:00

39 lines
930 B
Go

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
ctx context.Context
RBACErrors
}
func (c *CollectData) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Data")
}
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
}