diff --git a/config/crds/troubleshoot.sh_analyzers.yaml b/config/crds/troubleshoot.sh_analyzers.yaml index df2f1f8a..1f4f2453 100644 --- a/config/crds/troubleshoot.sh_analyzers.yaml +++ b/config/crds/troubleshoot.sh_analyzers.yaml @@ -1070,6 +1070,8 @@ spec: type: BoolString fileName: type: string + ignoreIfNoFiles: + type: boolean outcomes: items: properties: diff --git a/config/crds/troubleshoot.sh_preflights.yaml b/config/crds/troubleshoot.sh_preflights.yaml index 51f64544..6411ed97 100644 --- a/config/crds/troubleshoot.sh_preflights.yaml +++ b/config/crds/troubleshoot.sh_preflights.yaml @@ -1070,6 +1070,8 @@ spec: type: BoolString fileName: type: string + ignoreIfNoFiles: + type: boolean outcomes: items: properties: diff --git a/config/crds/troubleshoot.sh_supportbundles.yaml b/config/crds/troubleshoot.sh_supportbundles.yaml index 57ad4f4a..440be230 100644 --- a/config/crds/troubleshoot.sh_supportbundles.yaml +++ b/config/crds/troubleshoot.sh_supportbundles.yaml @@ -1101,6 +1101,8 @@ spec: type: BoolString fileName: type: string + ignoreIfNoFiles: + type: boolean outcomes: items: properties: diff --git a/pkg/analyze/text_analyze.go b/pkg/analyze/text_analyze.go index ec9fa067..f7119084 100644 --- a/pkg/analyze/text_analyze.go +++ b/pkg/analyze/text_analyze.go @@ -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 diff --git a/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go b/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go index 7aef1096..889371ff 100644 --- a/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go @@ -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 { diff --git a/schemas/analyzer-troubleshoot-v1beta2.json b/schemas/analyzer-troubleshoot-v1beta2.json index 79800998..b2ec7c59 100644 --- a/schemas/analyzer-troubleshoot-v1beta2.json +++ b/schemas/analyzer-troubleshoot-v1beta2.json @@ -1615,6 +1615,9 @@ "fileName": { "type": "string" }, + "ignoreIfNoFiles": { + "type": "boolean" + }, "outcomes": { "type": "array", "items": { diff --git a/schemas/preflight-troubleshoot-v1beta2.json b/schemas/preflight-troubleshoot-v1beta2.json index f4d7ab09..58ba4d4c 100644 --- a/schemas/preflight-troubleshoot-v1beta2.json +++ b/schemas/preflight-troubleshoot-v1beta2.json @@ -1615,6 +1615,9 @@ "fileName": { "type": "string" }, + "ignoreIfNoFiles": { + "type": "boolean" + }, "outcomes": { "type": "array", "items": { diff --git a/schemas/supportbundle-troubleshoot-v1beta2.json b/schemas/supportbundle-troubleshoot-v1beta2.json index b8a3b12e..45e6c7bf 100644 --- a/schemas/supportbundle-troubleshoot-v1beta2.json +++ b/schemas/supportbundle-troubleshoot-v1beta2.json @@ -1661,6 +1661,9 @@ "fileName": { "type": "string" }, + "ignoreIfNoFiles": { + "type": "boolean" + }, "outcomes": { "type": "array", "items": {