Skip to content

Commit

Permalink
Merge pull request #101 from replicatedhq/revert-100-regex-analyzer
Browse files Browse the repository at this point in the history
Revert "Regex analyzer"
  • Loading branch information
marccampbell authored Dec 19, 2019
2 parents 8ca92b4 + 806b2fb commit af9defc
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 297 deletions.
2 changes: 1 addition & 1 deletion cmd/preflight/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func runPreflights(v *viper.Viper, arg string) error {

preflight := troubleshootv1beta1.Preflight{}
if err := yaml.Unmarshal([]byte(preflightContent), &preflight); err != nil {
return fmt.Errorf("unable to parse %s as a preflight, error: %s", arg, err.Error())
return fmt.Errorf("unable to parse %s as a preflight", arg)
}

s := spin.New()
Expand Down
24 changes: 0 additions & 24 deletions examples/preflight/postgres-connection-valid.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions pkg/analyze/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ func Analyze(analyzer *troubleshootv1beta1.Analyze, getFile getCollectedFileCont
}
return analyzeDistribution(analyzer.Distribution, getFile)
}
if analyzer.RegEx != nil {
if analyzer.RegEx.Exclude {
return nil, nil
}
return analyzeRegex(analyzer.RegEx, getFile)
}

return nil, errors.New("invalid analyzer")
}
166 changes: 0 additions & 166 deletions pkg/analyze/regex.go

This file was deleted.

57 changes: 0 additions & 57 deletions pkg/analyze/regex_test.go

This file was deleted.

8 changes: 0 additions & 8 deletions pkg/apis/troubleshoot/v1beta1/analyzer_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ type Distribution struct {
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
}

type RegEx struct {
AnalyzeMeta `json:",inline" yaml:",inline"`
CollectorName string `json:"collectorName" yaml:"collectorName"`
Expression string `json:"expression" yaml:"expression"`
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
}

type AnalyzeMeta struct {
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
Exclude bool `json:"exclude,omitempty" yaml:"exclude,omitempty"`
Expand All @@ -97,5 +90,4 @@ type Analyze struct {
StatefulsetStatus *StatefulsetStatus `json:"statefulsetStatus,omitempty" yaml:"statefulsetStatus,omitempty"`
ContainerRuntime *ContainerRuntime `json:"containerRuntime,omitempty" yaml:"containerRuntime,omitempty"`
Distribution *Distribution `json:"distribution,omitempty" yaml:"distribution,omitempty"`
RegEx *RegEx `json:"regex,omitempty" yaml:"regex,omitempty"`
}
3 changes: 3 additions & 0 deletions pkg/apis/troubleshoot/v1beta1/collector_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Data struct {

type Run struct {
CollectorMeta `json:",inline" yaml:",inline"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Namespace string `json:"namespace" yaml:"namespace"`
Image string `json:"image" yaml:"image"`
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
Expand All @@ -53,6 +54,7 @@ type Run struct {

type Exec struct {
CollectorMeta `json:",inline" yaml:",inline"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Selector []string `json:"selector" yaml:"selector"`
Namespace string `json:"namespace" yaml:"namespace"`
ContainerName string `json:"containerName,omitempty" yaml:"containerName,omitempty"`
Expand All @@ -63,6 +65,7 @@ type Exec struct {

type Copy struct {
CollectorMeta `json:",inline" yaml:",inline"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Selector []string `json:"selector" yaml:"selector"`
Namespace string `json:"namespace" yaml:"namespace"`
ContainerPath string `json:"containerPath" yaml:"containerPath"`
Expand Down
32 changes: 0 additions & 32 deletions pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ func (in *Analyze) DeepCopyInto(out *Analyze) {
*out = new(Distribution)
(*in).DeepCopyInto(*out)
}
if in.RegEx != nil {
in, out := &in.RegEx, &out.RegEx
*out = new(RegEx)
(*in).DeepCopyInto(*out)
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Analyze.
Expand Down Expand Up @@ -1364,33 +1359,6 @@ func (in *Put) DeepCopy() *Put {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RegEx) DeepCopyInto(out *RegEx) {
*out = *in
out.AnalyzeMeta = in.AnalyzeMeta
if in.Outcomes != nil {
in, out := &in.Outcomes, &out.Outcomes
*out = make([]*Outcome, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(Outcome)
(*in).DeepCopyInto(*out)
}
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegEx.
func (in *RegEx) DeepCopy() *RegEx {
if in == nil {
return nil
}
out := new(RegEx)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResultRequest) DeepCopyInto(out *ResultRequest) {
*out = *in
Expand Down
5 changes: 4 additions & 1 deletion pkg/collect/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Copy(ctx *Context, copyCollector *troubleshootv1beta1.Copy) ([]byte, error)

if len(pods) > 0 {
for _, pod := range pods {
bundlePath := filepath.Join(copyCollector.CollectorName, pod.Namespace, pod.Name)
bundlePath := filepath.Join(copyCollector.Name, pod.Namespace, pod.Name)

files, copyErrors := copyFiles(ctx, client, pod, copyCollector)
if len(copyErrors) > 0 {
Expand Down Expand Up @@ -136,6 +136,9 @@ func (c CopyOutput) Redact() (CopyOutput, error) {
}

func getCopyErrosFileName(copyCollector *troubleshootv1beta1.Copy) string {
if len(copyCollector.Name) > 0 {
return fmt.Sprintf("%s-errors.json", copyCollector.Name)
}
if len(copyCollector.CollectorName) > 0 {
return fmt.Sprintf("%s-errors.json", copyCollector.CollectorName)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/collect/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func execWithoutTimeout(ctx *Context, execCollector *troubleshootv1beta1.Exec) (
for _, pod := range pods {
stdout, stderr, execErrors := getExecOutputs(ctx, client, pod, execCollector)

bundlePath := filepath.Join(execCollector.CollectorName, pod.Namespace, pod.Name)
bundlePath := filepath.Join(execCollector.Name, pod.Namespace, pod.Name)
if len(stdout) > 0 {
execOutput[filepath.Join(bundlePath, execCollector.CollectorName+"-stdout.txt")] = stdout
}
Expand Down Expand Up @@ -158,6 +158,9 @@ func (r ExecOutput) Redact() (ExecOutput, error) {
}

func getExecErrosFileName(execCollector *troubleshootv1beta1.Exec) string {
if len(execCollector.Name) > 0 {
return fmt.Sprintf("%s-errors.json", execCollector.Name)
}
if len(execCollector.CollectorName) > 0 {
return fmt.Sprintf("%s-errors.json", execCollector.CollectorName)
}
Expand Down
Loading

0 comments on commit af9defc

Please sign in to comment.