Allow text analyzer to not generate an error if no files match

This commit is contained in:
divolgin
2021-10-29 17:52:59 +00:00
parent 181df9c85b
commit 739ee666af
8 changed files with 27 additions and 7 deletions
@@ -1070,6 +1070,8 @@ spec:
type: BoolString
fileName:
type: string
ignoreIfNoFiles:
type: boolean
outcomes:
items:
properties:
@@ -1070,6 +1070,8 @@ spec:
type: BoolString
fileName:
type: string
ignoreIfNoFiles:
type: boolean
outcomes:
items:
properties:
@@ -1101,6 +1101,8 @@ spec:
type: BoolString
fileName:
type: string
ignoreIfNoFiles:
type: boolean
outcomes:
items:
properties:
+5 -1
View File
@@ -24,12 +24,16 @@ func analyzeTextAnalyze(analyzer *troubleshootv1beta2.TextAnalyze, getCollectedF
}
if len(collected) == 0 {
if analyzer.IgnoreIfNoFiles {
return nil, nil
}
return []*AnalyzeResult{
{
Title: checkName,
IconKey: "kubernetes_text_analyze",
IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg",
IsFail: false,
IsWarn: true,
Message: "No matching files",
},
}, nil
@@ -117,12 +117,13 @@ type NodeResourceSelectors struct {
}
type TextAnalyze struct {
AnalyzeMeta `json:",inline" yaml:",inline"`
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
FileName string `json:"fileName,omitempty" yaml:"fileName,omitempty"`
RegexPattern string `json:"regex,omitempty" yaml:"regex,omitempty"`
RegexGroups string `json:"regexGroups,omitempty" yaml:"regexGroups,omitempty"`
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
AnalyzeMeta `json:",inline" yaml:",inline"`
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
FileName string `json:"fileName,omitempty" yaml:"fileName,omitempty"`
RegexPattern string `json:"regex,omitempty" yaml:"regex,omitempty"`
RegexGroups string `json:"regexGroups,omitempty" yaml:"regexGroups,omitempty"`
IgnoreIfNoFiles bool `json:"ignoreIfNoFiles,omitempty" yaml:"ignoreIfNoFiles,omitempty"`
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
}
type DatabaseAnalyze struct {
@@ -1615,6 +1615,9 @@
"fileName": {
"type": "string"
},
"ignoreIfNoFiles": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {
@@ -1615,6 +1615,9 @@
"fileName": {
"type": "string"
},
"ignoreIfNoFiles": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {
@@ -1661,6 +1661,9 @@
"fileName": {
"type": "string"
},
"ignoreIfNoFiles": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {