Skip to content

Commit

Permalink
Merge pull request #92 from replicatedhq/optional-collectors
Browse files Browse the repository at this point in the history
Optional collectors and analyzers
  • Loading branch information
marccampbell committed Dec 18, 2019
2 parents fd257b5 + c61acdc commit 1ee6629
Show file tree
Hide file tree
Showing 19 changed files with 250 additions and 245 deletions.
7 changes: 1 addition & 6 deletions cmd/preflight/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ that a cluster meets the requirements to run an application.`,
},
RunE: func(cmd *cobra.Command, args []string) error {
v := viper.GetViper()

if len(args) == 0 {
return runPreflightsCRD(v)
}

return runPreflightsNoCRD(v, args[0])
return runPreflights(v, args[0])
},
}

Expand Down
20 changes: 12 additions & 8 deletions cmd/preflight/cli/run_nocrd.go → cmd/preflight/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"gopkg.in/yaml.v2"
)

func runPreflightsNoCRD(v *viper.Viper, arg string) error {
func runPreflights(v *viper.Viper, arg string) error {
fmt.Print(cursor.Hide())
defer fmt.Print(cursor.Show())

Expand Down Expand Up @@ -112,7 +112,9 @@ func runPreflightsNoCRD(v *viper.Viper, arg string) error {
continue
}

analyzeResults = append(analyzeResults, analyzeResult)
if analyzeResult != nil {
analyzeResults = append(analyzeResults, analyzeResult)
}
}

finishedCh <- true
Expand Down Expand Up @@ -156,12 +158,14 @@ func runCollectors(v *viper.Viper, preflight troubleshootv1beta1.Preflight) (map
return nil, errors.Wrap(err, "failed to run collector")
}

output, err := parseCollectorOutput(string(result))
if err != nil {
return nil, errors.Wrap(err, "failed to parse collector output")
}
for k, v := range output {
allCollectedData[k] = v
if result != nil {
output, err := parseCollectorOutput(string(result))
if err != nil {
return nil, errors.Wrap(err, "failed to parse collector output")
}
for k, v := range output {
allCollectedData[k] = v
}
}
}

Expand Down
107 changes: 0 additions & 107 deletions cmd/preflight/cli/run_crd.go

This file was deleted.

7 changes: 1 addition & 6 deletions cmd/troubleshoot/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ from a server that can be used to assist when troubleshooting a server.`,
v := viper.GetViper()

logger.SetQuiet(v.GetBool("quiet"))

if len(args) == 0 {
return runTroubleshootCRD(v)
}

return runTroubleshootNoCRD(v, args[0])
return runTroubleshoot(v, args[0])
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"gopkg.in/yaml.v2"
)

func runTroubleshootNoCRD(v *viper.Viper, arg string) error {
func runTroubleshoot(v *viper.Viper, arg string) error {
fmt.Print(cursor.Hide())
defer fmt.Print(cursor.Show())

Expand Down Expand Up @@ -179,10 +179,12 @@ func runCollectors(v *viper.Viper, collector troubleshootv1beta1.Collector, prog
continue
}

err = parseAndSaveCollectorOutput(string(result), bundlePath)
if err != nil {
progressChan <- fmt.Errorf("failed to parse collector spec %q: %v", collector.GetDisplayName(), err)
continue
if result != nil {
err = parseAndSaveCollectorOutput(string(result), bundlePath)
if err != nil {
progressChan <- fmt.Errorf("failed to parse collector spec %q: %v", collector.GetDisplayName(), err)
continue
}
}
}

Expand Down
106 changes: 0 additions & 106 deletions cmd/troubleshoot/cli/run_crd.go

This file was deleted.

20 changes: 20 additions & 0 deletions config/crds/troubleshoot.replicated.com_analyzers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
Expand Down Expand Up @@ -437,6 +439,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
Expand Down Expand Up @@ -478,6 +482,8 @@ spec:
type: string
customResourceDefinitionName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
Expand Down Expand Up @@ -518,6 +524,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
name:
type: string
namespace:
Expand Down Expand Up @@ -563,6 +571,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
Expand Down Expand Up @@ -602,6 +612,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
Expand Down Expand Up @@ -644,6 +656,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
ingressName:
type: string
namespace:
Expand Down Expand Up @@ -689,6 +703,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
key:
type: string
namespace:
Expand Down Expand Up @@ -736,6 +752,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
name:
type: string
namespace:
Expand Down Expand Up @@ -781,6 +799,8 @@ spec:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
Expand Down

0 comments on commit 1ee6629

Please sign in to comment.