Skip to content

Commit ea7756f

Browse files
authored
Merge pull request #479 from replicatedhq/divolgin/no-files
Allow text analyzer to not generate an error if no files match
2 parents 181df9c + 739ee66 commit ea7756f

File tree

8 files changed

+27
-7
lines changed

8 files changed

+27
-7
lines changed

config/crds/troubleshoot.sh_analyzers.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,8 @@ spec:
10701070
type: BoolString
10711071
fileName:
10721072
type: string
1073+
ignoreIfNoFiles:
1074+
type: boolean
10731075
outcomes:
10741076
items:
10751077
properties:

config/crds/troubleshoot.sh_preflights.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,8 @@ spec:
10701070
type: BoolString
10711071
fileName:
10721072
type: string
1073+
ignoreIfNoFiles:
1074+
type: boolean
10731075
outcomes:
10741076
items:
10751077
properties:

config/crds/troubleshoot.sh_supportbundles.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,8 @@ spec:
11011101
type: BoolString
11021102
fileName:
11031103
type: string
1104+
ignoreIfNoFiles:
1105+
type: boolean
11041106
outcomes:
11051107
items:
11061108
properties:

pkg/analyze/text_analyze.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ func analyzeTextAnalyze(analyzer *troubleshootv1beta2.TextAnalyze, getCollectedF
2424
}
2525

2626
if len(collected) == 0 {
27+
if analyzer.IgnoreIfNoFiles {
28+
return nil, nil
29+
}
30+
2731
return []*AnalyzeResult{
2832
{
2933
Title: checkName,
3034
IconKey: "kubernetes_text_analyze",
3135
IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg",
32-
IsFail: false,
36+
IsWarn: true,
3337
Message: "No matching files",
3438
},
3539
}, nil

pkg/apis/troubleshoot/v1beta2/analyzer_shared.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ type NodeResourceSelectors struct {
117117
}
118118

119119
type TextAnalyze struct {
120-
AnalyzeMeta `json:",inline" yaml:",inline"`
121-
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
122-
FileName string `json:"fileName,omitempty" yaml:"fileName,omitempty"`
123-
RegexPattern string `json:"regex,omitempty" yaml:"regex,omitempty"`
124-
RegexGroups string `json:"regexGroups,omitempty" yaml:"regexGroups,omitempty"`
125-
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
120+
AnalyzeMeta `json:",inline" yaml:",inline"`
121+
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
122+
FileName string `json:"fileName,omitempty" yaml:"fileName,omitempty"`
123+
RegexPattern string `json:"regex,omitempty" yaml:"regex,omitempty"`
124+
RegexGroups string `json:"regexGroups,omitempty" yaml:"regexGroups,omitempty"`
125+
IgnoreIfNoFiles bool `json:"ignoreIfNoFiles,omitempty" yaml:"ignoreIfNoFiles,omitempty"`
126+
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
126127
}
127128

128129
type DatabaseAnalyze struct {

schemas/analyzer-troubleshoot-v1beta2.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,9 @@
16151615
"fileName": {
16161616
"type": "string"
16171617
},
1618+
"ignoreIfNoFiles": {
1619+
"type": "boolean"
1620+
},
16181621
"outcomes": {
16191622
"type": "array",
16201623
"items": {

schemas/preflight-troubleshoot-v1beta2.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,9 @@
16151615
"fileName": {
16161616
"type": "string"
16171617
},
1618+
"ignoreIfNoFiles": {
1619+
"type": "boolean"
1620+
},
16181621
"outcomes": {
16191622
"type": "array",
16201623
"items": {

schemas/supportbundle-troubleshoot-v1beta2.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,9 @@
16611661
"fileName": {
16621662
"type": "string"
16631663
},
1664+
"ignoreIfNoFiles": {
1665+
"type": "boolean"
1666+
},
16641667
"outcomes": {
16651668
"type": "array",
16661669
"items": {

0 commit comments

Comments
 (0)