mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-09-03 00:47:17 +00:00
Merge pull request #82 from replicatedhq/divolgin/data
support for data collector
This commit is contained in:
@@ -32,6 +32,12 @@ type Logs struct {
|
||||
Limits *LogLimits `json:"limits,omitempty" yaml:"omitempty"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
CollectorMeta `json:",inline" yaml:",inline"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Data string `json:"data" yaml:"data"`
|
||||
}
|
||||
|
||||
type Run struct {
|
||||
CollectorMeta `json:",inline" yaml:",inline"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
@@ -98,6 +104,7 @@ type Collect struct {
|
||||
Logs *Logs `json:"logs,omitempty" yaml:"logs,omitempty"`
|
||||
Run *Run `json:"run,omitempty" yaml:"run,omitempty"`
|
||||
Exec *Exec `json:"exec,omitempty" yaml:"exec,omitempty"`
|
||||
Data *Data `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
Copy *Copy `json:"copy,omitempty" yaml:"copy,omitempty"`
|
||||
HTTP *HTTP `json:"http,omitempty" yaml:"http,omitempty"`
|
||||
}
|
||||
|
||||
@@ -435,6 +435,11 @@ func (in *Collect) DeepCopyInto(out *Collect) {
|
||||
*out = new(Exec)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Data != nil {
|
||||
in, out := &in.Data, &out.Data
|
||||
*out = new(Data)
|
||||
**out = **in
|
||||
}
|
||||
if in.Copy != nil {
|
||||
in, out := &in.Copy, &out.Copy
|
||||
*out = new(Copy)
|
||||
@@ -778,6 +783,22 @@ func (in *CustomResourceDefinition) DeepCopy() *CustomResourceDefinition {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Data) DeepCopyInto(out *Data) {
|
||||
*out = *in
|
||||
out.CollectorMeta = in.CollectorMeta
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Data.
|
||||
func (in *Data) DeepCopy() *Data {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Data)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) {
|
||||
*out = *in
|
||||
|
||||
@@ -40,6 +40,9 @@ func (c *Collector) RunCollectorSync() ([]byte, error) {
|
||||
if c.Collect.Exec != nil {
|
||||
return Exec(c.GetContext(), c.Collect.Exec)
|
||||
}
|
||||
if c.Collect.Data != nil {
|
||||
return Data(c.GetContext(), c.Collect.Data)
|
||||
}
|
||||
if c.Collect.Copy != nil {
|
||||
return Copy(c.GetContext(), c.Collect.Copy)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package collect
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"path/filepath"
|
||||
|
||||
troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
|
||||
)
|
||||
|
||||
type DataOutput map[string][]byte
|
||||
|
||||
func Data(ctx *Context, dataCollector *troubleshootv1beta1.Data) ([]byte, error) {
|
||||
bundlePath := filepath.Join(dataCollector.Name, dataCollector.CollectorName)
|
||||
dataOutput := DataOutput{
|
||||
bundlePath: []byte(dataCollector.Data),
|
||||
}
|
||||
|
||||
b, err := json.MarshalIndent(dataOutput, "", " ")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
Reference in New Issue
Block a user