func (cr *Collector) CollectServiceLogs(service string) ([]string, error) {
	scp, err := newScpClient(cr.scpConfig)
	if err != nil {
		return nil, err
	}
	defer scp.Close()
	paths, err := scp.GetServicesFilePaths(service)
	if err != nil {
		return nil, err
	}
	results := upload(scp, cr.Output, paths)
	return results, nil
}
CollectServiceLogs fetches the log file(s) for the services name matching basic shell file name pattern
and uploads all the file(s).
It returns the list locations where the log(s) were uploaded.
package collector
import (
	"io"
	"log"
	"path/filepath"
	"sync"
	"github.com/coreos/ktestutil/log-collector/pkg/fluentd"
	"github.com/coreos/ktestutil/log-collector/pkg/local"
	"github.com/coreos/ktestutil/log-collector/pkg/s3"
	"k8s.io/client-go/kubernetes"
)
type Output interface {
	Put(io.ReadSeeker, string) (string, error)
}
type Collector struct {
	scpConfig *scpConfig
	namespace string
	k8s       kubernetes.Interface
	Output Output
}
type Config struct {
	RemoteUser    string
	RemotePort    int32
	RemoteKeyFile string
	K8sClient     kubernetes.Interface
	Namespace     string
}
func New(c *Config) *Collector {
	return &Collector{
		scpConfig: &scpConfig{
			user:            c.RemoteUser,
			port:            c.RemotePort,
			identifyKeyFile: c.RemoteKeyFile,
		},
		namespace: c.Namespace,
		k8s:       c.K8sClient,
	}
}
func (cr *Collector) SetOutputToLocal(dstDir string) error {
	l, err := local.New(&local.Config{
		Dir: dstDir,
	})
	if err != nil {
		return err
	}
	cr.Output = l
	return nil
}
func (cr *Collector) SetOutputToS3(keyId, keySecret, region, bucketName, bucketPrefix string) error {
	s3, err := s3.New(&s3.Config{
		AccessKeyId:     keyId,
		AccessKeySecret: keySecret,
		BucketName:      bucketName,
		BucketPrefix:    bucketPrefix,
		Region:          region,
	})
	if err != nil {
		return err
	}
	cr.Output = s3
	return nil
}
func (cr *Collector) Start() error {
	if err := fluentd.CreateAssets(cr.k8s, cr.namespace); err != nil {
		return err
	}
	host, err := fluentd.GetNodeAddressWithMaster(cr.k8s, cr.namespace)
	if err != nil {
		return err
	}
	cr.scpConfig.host = host
	return nil
}
func (cr *Collector) CollectPodLogs(pod string) ([]string, error) {
	scp, err := newScpClient(cr.scpConfig)
	if err != nil {
		return nil, err
	}
	defer scp.Close()
	paths, err := scp.GetPodsFilePaths(pod)
	if err != nil {
		return nil, err
	}
	results := upload(scp, cr.Output, paths)
	return results, nil
}