Skip to content

Commit 1ee6629

Browse files
authored
Merge pull request #92 from replicatedhq/optional-collectors
Optional collectors and analyzers
2 parents fd257b5 + c61acdc commit 1ee6629

19 files changed

+250
-245
lines changed

cmd/preflight/cli/root.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ that a cluster meets the requirements to run an application.`,
2727
},
2828
RunE: func(cmd *cobra.Command, args []string) error {
2929
v := viper.GetViper()
30-
31-
if len(args) == 0 {
32-
return runPreflightsCRD(v)
33-
}
34-
35-
return runPreflightsNoCRD(v, args[0])
30+
return runPreflights(v, args[0])
3631
},
3732
}
3833

cmd/preflight/cli/run_nocrd.go renamed to cmd/preflight/cli/run.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"gopkg.in/yaml.v2"
2323
)
2424

25-
func runPreflightsNoCRD(v *viper.Viper, arg string) error {
25+
func runPreflights(v *viper.Viper, arg string) error {
2626
fmt.Print(cursor.Hide())
2727
defer fmt.Print(cursor.Show())
2828

@@ -112,7 +112,9 @@ func runPreflightsNoCRD(v *viper.Viper, arg string) error {
112112
continue
113113
}
114114

115-
analyzeResults = append(analyzeResults, analyzeResult)
115+
if analyzeResult != nil {
116+
analyzeResults = append(analyzeResults, analyzeResult)
117+
}
116118
}
117119

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

159-
output, err := parseCollectorOutput(string(result))
160-
if err != nil {
161-
return nil, errors.Wrap(err, "failed to parse collector output")
162-
}
163-
for k, v := range output {
164-
allCollectedData[k] = v
161+
if result != nil {
162+
output, err := parseCollectorOutput(string(result))
163+
if err != nil {
164+
return nil, errors.Wrap(err, "failed to parse collector output")
165+
}
166+
for k, v := range output {
167+
allCollectedData[k] = v
168+
}
165169
}
166170
}
167171

cmd/preflight/cli/run_crd.go

Lines changed: 0 additions & 107 deletions
This file was deleted.

cmd/troubleshoot/cli/root.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ from a server that can be used to assist when troubleshooting a server.`,
3030
v := viper.GetViper()
3131

3232
logger.SetQuiet(v.GetBool("quiet"))
33-
34-
if len(args) == 0 {
35-
return runTroubleshootCRD(v)
36-
}
37-
38-
return runTroubleshootNoCRD(v, args[0])
33+
return runTroubleshoot(v, args[0])
3934
},
4035
}
4136

cmd/troubleshoot/cli/run_nocrd.go renamed to cmd/troubleshoot/cli/run.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"gopkg.in/yaml.v2"
2323
)
2424

25-
func runTroubleshootNoCRD(v *viper.Viper, arg string) error {
25+
func runTroubleshoot(v *viper.Viper, arg string) error {
2626
fmt.Print(cursor.Hide())
2727
defer fmt.Print(cursor.Show())
2828

@@ -179,10 +179,12 @@ func runCollectors(v *viper.Viper, collector troubleshootv1beta1.Collector, prog
179179
continue
180180
}
181181

182-
err = parseAndSaveCollectorOutput(string(result), bundlePath)
183-
if err != nil {
184-
progressChan <- fmt.Errorf("failed to parse collector spec %q: %v", collector.GetDisplayName(), err)
185-
continue
182+
if result != nil {
183+
err = parseAndSaveCollectorOutput(string(result), bundlePath)
184+
if err != nil {
185+
progressChan <- fmt.Errorf("failed to parse collector spec %q: %v", collector.GetDisplayName(), err)
186+
continue
187+
}
186188
}
187189
}
188190

cmd/troubleshoot/cli/run_crd.go

Lines changed: 0 additions & 106 deletions
This file was deleted.

config/crds/troubleshoot.replicated.com_analyzers.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ spec:
398398
properties:
399399
checkName:
400400
type: string
401+
exclude:
402+
type: boolean
401403
outcomes:
402404
items:
403405
properties:
@@ -437,6 +439,8 @@ spec:
437439
properties:
438440
checkName:
439441
type: string
442+
exclude:
443+
type: boolean
440444
outcomes:
441445
items:
442446
properties:
@@ -478,6 +482,8 @@ spec:
478482
type: string
479483
customResourceDefinitionName:
480484
type: string
485+
exclude:
486+
type: boolean
481487
outcomes:
482488
items:
483489
properties:
@@ -518,6 +524,8 @@ spec:
518524
properties:
519525
checkName:
520526
type: string
527+
exclude:
528+
type: boolean
521529
name:
522530
type: string
523531
namespace:
@@ -563,6 +571,8 @@ spec:
563571
properties:
564572
checkName:
565573
type: string
574+
exclude:
575+
type: boolean
566576
outcomes:
567577
items:
568578
properties:
@@ -602,6 +612,8 @@ spec:
602612
properties:
603613
checkName:
604614
type: string
615+
exclude:
616+
type: boolean
605617
outcomes:
606618
items:
607619
properties:
@@ -644,6 +656,8 @@ spec:
644656
properties:
645657
checkName:
646658
type: string
659+
exclude:
660+
type: boolean
647661
ingressName:
648662
type: string
649663
namespace:
@@ -689,6 +703,8 @@ spec:
689703
properties:
690704
checkName:
691705
type: string
706+
exclude:
707+
type: boolean
692708
key:
693709
type: string
694710
namespace:
@@ -736,6 +752,8 @@ spec:
736752
properties:
737753
checkName:
738754
type: string
755+
exclude:
756+
type: boolean
739757
name:
740758
type: string
741759
namespace:
@@ -781,6 +799,8 @@ spec:
781799
properties:
782800
checkName:
783801
type: string
802+
exclude:
803+
type: boolean
784804
outcomes:
785805
items:
786806
properties:

0 commit comments

Comments
 (0)