From 942234da80e519e591cd9b30ce92d4970f9feadf Mon Sep 17 00:00:00 2001 From: Pavan Sokke Nagaraj Date: Wed, 23 Feb 2022 15:07:51 -0500 Subject: [PATCH] Add `strict` flag to Analyzers and ResultAnalyzers (#539) * add strict flag to Analyzer/AnalyzerMeta and regenerate schemas and controller-gen code * map analyzer strict to result * Update stdout for human and json format * fix review comment * update interactive result * update interactive results * Update types.go * Update upload_results.go * print strict when only true --- cmd/preflight/cli/interactive_results.go | 7 ++ cmd/preflight/cli/stdout_results.go | 12 +++ cmd/preflight/cli/upload_results.go | 1 + config/crds/troubleshoot.sh_analyzers.yaml | 48 +++++++++ .../crds/troubleshoot.sh_hostcollectors.yaml | 34 ++++++ .../crds/troubleshoot.sh_hostpreflights.yaml | 34 ++++++ config/crds/troubleshoot.sh_preflights.yaml | 48 +++++++++ .../crds/troubleshoot.sh_supportbundles.yaml | 48 +++++++++ .../fake/clientset_generated.go | 5 +- .../troubleshootclientset/fake/register.go | 2 +- pkg/analyze/analyzer.go | 51 ++++++++- .../troubleshoot/v1beta2/analyzer_shared.go | 1 + .../v1beta2/zz_generated.deepcopy.go | 1 + pkg/preflight/types.go | 1 + schemas/analyzer-troubleshoot-v1beta2.json | 101 +++++++++++++++++- schemas/preflight-troubleshoot-v1beta2.json | 101 +++++++++++++++++- .../supportbundle-troubleshoot-v1beta2.json | 101 +++++++++++++++++- 17 files changed, 576 insertions(+), 20 deletions(-) diff --git a/cmd/preflight/cli/interactive_results.go b/cmd/preflight/cli/interactive_results.go index 9098e117..cd9d7704 100644 --- a/cmd/preflight/cli/interactive_results.go +++ b/cmd/preflight/cli/interactive_results.go @@ -139,6 +139,9 @@ func drawPreflightTable(analyzeResults []*analyzerunner.AnalyzeResult) { for i, analyzeResult := range analyzeResults { title := analyzeResult.Title + if analyzeResult.Strict { + title = title + fmt.Sprintf(" (Strict: %t)", analyzeResult.Strict) + } if analyzeResult.IsPass { title = fmt.Sprintf("✔ %s", title) } else if analyzeResult.IsWarn { @@ -255,6 +258,10 @@ func save(preflightName string, outputPath string, analyzeResults []*analyzerunn result = result + fmt.Sprintf("URI: %s\n", analyzeResult.URI) } + if analyzeResult.Strict { + result = result + fmt.Sprintf("Strict: %t\n", analyzeResult.Strict) + } + result = result + "\n------------\n" results = results + result diff --git a/cmd/preflight/cli/stdout_results.go b/cmd/preflight/cli/stdout_results.go index 66b1f59b..03a78a5f 100644 --- a/cmd/preflight/cli/stdout_results.go +++ b/cmd/preflight/cli/stdout_results.go @@ -42,6 +42,7 @@ func showStdoutResultsJSON(preflightName string, analyzeResults []*analyzerunner Title string `json:"title"` Message string `json:"message"` URI string `json:"uri,omitempty"` + Strict bool `json:"strict,omitempty"` } type Output struct { Pass []ResultOutput `json:"pass,omitempty"` @@ -62,6 +63,10 @@ func showStdoutResultsJSON(preflightName string, analyzeResults []*analyzerunner URI: analyzeResult.URI, } + if analyzeResult.Strict { + resultOutput.Strict = analyzeResult.Strict + } + if analyzeResult.IsPass { output.Pass = append(output.Pass, resultOutput) } else if analyzeResult.IsWarn { @@ -91,6 +96,13 @@ func outputResult(analyzeResult *analyzerunner.AnalyzeResult) bool { } else if analyzeResult.IsFail { fmt.Printf(" --- FAIL: %s\n", analyzeResult.Title) fmt.Printf(" --- %s\n", analyzeResult.Message) + } + + if analyzeResult.Strict { + fmt.Printf(" --- Strict: %t\n", analyzeResult.Strict) + } + + if analyzeResult.IsFail { return true } return false diff --git a/cmd/preflight/cli/upload_results.go b/cmd/preflight/cli/upload_results.go index 1eacdd6d..dcf5793a 100644 --- a/cmd/preflight/cli/upload_results.go +++ b/cmd/preflight/cli/upload_results.go @@ -17,6 +17,7 @@ func uploadResults(uri string, analyzeResults []*analyzerunner.AnalyzeResult) er } for _, analyzeResult := range analyzeResults { uploadPreflightResult := &preflight.UploadPreflightResult{ + Strict: analyzeResult.Strict, IsFail: analyzeResult.IsFail, IsWarn: analyzeResult.IsWarn, IsPass: analyzeResult.IsPass, diff --git a/config/crds/troubleshoot.sh_analyzers.yaml b/config/crds/troubleshoot.sh_analyzers.yaml index ce1d8b5f..334ee35c 100644 --- a/config/crds/troubleshoot.sh_analyzers.yaml +++ b/config/crds/troubleshoot.sh_analyzers.yaml @@ -81,6 +81,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - namespace - outcomes @@ -127,6 +129,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -168,6 +172,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -215,6 +221,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - configMapName - namespace @@ -258,6 +266,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -301,6 +311,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - customResourceDefinitionName - outcomes @@ -351,6 +363,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -393,6 +407,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -436,6 +452,8 @@ spec: type: array registryName: type: string + strict: + type: BoolString required: - outcomes - registryName @@ -482,6 +500,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - ingressName - namespace @@ -533,6 +553,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -579,6 +601,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - namespace - outcomes @@ -625,6 +649,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -693,6 +719,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -738,6 +766,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -784,6 +814,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -828,6 +860,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -882,6 +916,8 @@ spec: items: type: string type: array + strict: + type: BoolString required: - name - outcomes @@ -931,6 +967,8 @@ spec: type: array secretName: type: string + strict: + type: BoolString required: - namespace - outcomes @@ -982,6 +1020,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -1026,6 +1066,8 @@ spec: type: array storageClassName: type: string + strict: + type: BoolString required: - outcomes - storageClassName @@ -1068,6 +1110,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -1119,6 +1163,8 @@ spec: type: string regexGroups: type: string + strict: + type: BoolString required: - outcomes type: object @@ -1130,6 +1176,8 @@ spec: type: BoolString reportFileGlob: type: string + strict: + type: BoolString required: - reportFileGlob type: object diff --git a/config/crds/troubleshoot.sh_hostcollectors.yaml b/config/crds/troubleshoot.sh_hostcollectors.yaml index 02128242..85f3218a 100644 --- a/config/crds/troubleshoot.sh_hostcollectors.yaml +++ b/config/crds/troubleshoot.sh_hostcollectors.yaml @@ -82,6 +82,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - includeUnmountedPartitions - minimumAcceptableSize @@ -127,6 +129,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -168,6 +172,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -211,6 +217,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -254,6 +262,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -295,6 +305,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -336,6 +348,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -379,6 +393,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -422,6 +438,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -463,6 +481,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -504,6 +524,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -545,6 +567,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -588,6 +612,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -631,6 +657,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -674,6 +702,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -717,6 +747,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -758,6 +790,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object diff --git a/config/crds/troubleshoot.sh_hostpreflights.yaml b/config/crds/troubleshoot.sh_hostpreflights.yaml index 4ca46017..83d32c7c 100644 --- a/config/crds/troubleshoot.sh_hostpreflights.yaml +++ b/config/crds/troubleshoot.sh_hostpreflights.yaml @@ -82,6 +82,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - includeUnmountedPartitions - minimumAcceptableSize @@ -127,6 +129,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -168,6 +172,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -211,6 +217,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -254,6 +262,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -295,6 +305,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -336,6 +348,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -379,6 +393,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -422,6 +438,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -463,6 +481,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -504,6 +524,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -545,6 +567,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -588,6 +612,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -631,6 +657,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -674,6 +702,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -717,6 +747,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -758,6 +790,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object diff --git a/config/crds/troubleshoot.sh_preflights.yaml b/config/crds/troubleshoot.sh_preflights.yaml index 41f694d7..3464d5ae 100644 --- a/config/crds/troubleshoot.sh_preflights.yaml +++ b/config/crds/troubleshoot.sh_preflights.yaml @@ -81,6 +81,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - namespace - outcomes @@ -127,6 +129,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -168,6 +172,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -215,6 +221,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - configMapName - namespace @@ -258,6 +266,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -301,6 +311,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - customResourceDefinitionName - outcomes @@ -351,6 +363,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -393,6 +407,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -436,6 +452,8 @@ spec: type: array registryName: type: string + strict: + type: BoolString required: - outcomes - registryName @@ -482,6 +500,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - ingressName - namespace @@ -533,6 +553,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -579,6 +601,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - namespace - outcomes @@ -625,6 +649,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -693,6 +719,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -738,6 +766,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -784,6 +814,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -828,6 +860,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -882,6 +916,8 @@ spec: items: type: string type: array + strict: + type: BoolString required: - name - outcomes @@ -931,6 +967,8 @@ spec: type: array secretName: type: string + strict: + type: BoolString required: - namespace - outcomes @@ -982,6 +1020,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -1026,6 +1066,8 @@ spec: type: array storageClassName: type: string + strict: + type: BoolString required: - outcomes - storageClassName @@ -1068,6 +1110,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -1119,6 +1163,8 @@ spec: type: string regexGroups: type: string + strict: + type: BoolString required: - outcomes type: object @@ -1130,6 +1176,8 @@ spec: type: BoolString reportFileGlob: type: string + strict: + type: BoolString required: - reportFileGlob type: object diff --git a/config/crds/troubleshoot.sh_supportbundles.yaml b/config/crds/troubleshoot.sh_supportbundles.yaml index 856b47ea..19f39b97 100644 --- a/config/crds/troubleshoot.sh_supportbundles.yaml +++ b/config/crds/troubleshoot.sh_supportbundles.yaml @@ -112,6 +112,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - namespace - outcomes @@ -158,6 +160,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -199,6 +203,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -246,6 +252,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - configMapName - namespace @@ -289,6 +297,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -332,6 +342,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - customResourceDefinitionName - outcomes @@ -382,6 +394,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -424,6 +438,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -467,6 +483,8 @@ spec: type: array registryName: type: string + strict: + type: BoolString required: - outcomes - registryName @@ -513,6 +531,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - ingressName - namespace @@ -564,6 +584,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -610,6 +632,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - namespace - outcomes @@ -656,6 +680,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -724,6 +750,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -769,6 +797,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -815,6 +845,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -859,6 +891,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - collectorName - outcomes @@ -913,6 +947,8 @@ spec: items: type: string type: array + strict: + type: BoolString required: - name - outcomes @@ -962,6 +998,8 @@ spec: type: array secretName: type: string + strict: + type: BoolString required: - namespace - outcomes @@ -1013,6 +1051,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - name - outcomes @@ -1057,6 +1097,8 @@ spec: type: array storageClassName: type: string + strict: + type: BoolString required: - outcomes - storageClassName @@ -1099,6 +1141,8 @@ spec: type: object type: object type: array + strict: + type: BoolString required: - outcomes type: object @@ -1150,6 +1194,8 @@ spec: type: string regexGroups: type: string + strict: + type: BoolString required: - outcomes type: object @@ -1161,6 +1207,8 @@ spec: type: BoolString reportFileGlob: type: string + strict: + type: BoolString required: - reportFileGlob type: object diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/clientset_generated.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/clientset_generated.go index a6ef3f96..01dcb504 100644 --- a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/clientset_generated.go +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/clientset_generated.go @@ -75,7 +75,10 @@ func (c *Clientset) Tracker() testing.ObjectTracker { return c.tracker } -var _ clientset.Interface = &Clientset{} +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) // TroubleshootV1beta1 retrieves the TroubleshootV1beta1Client func (c *Clientset) TroubleshootV1beta1() troubleshootv1beta1.TroubleshootV1beta1Interface { diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/register.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/register.go index 8010c884..89d94f58 100644 --- a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/register.go +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/register.go @@ -29,7 +29,7 @@ import ( var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) -var parameterCodec = runtime.NewParameterCodec(scheme) + var localSchemeBuilder = runtime.SchemeBuilder{ troubleshootv1beta1.AddToScheme, troubleshootv1beta2.AddToScheme, diff --git a/pkg/analyze/analyzer.go b/pkg/analyze/analyzer.go index 1542e39b..582eeebe 100644 --- a/pkg/analyze/analyzer.go +++ b/pkg/analyze/analyzer.go @@ -14,6 +14,7 @@ type AnalyzeResult struct { IsPass bool IsFail bool IsWarn bool + Strict bool Title string Message string @@ -94,6 +95,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.ClusterVersion.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.StorageClass != nil { @@ -108,6 +110,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.StorageClass.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.CustomResourceDefinition != nil { @@ -122,6 +125,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.CustomResourceDefinition.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.Ingress != nil { @@ -136,6 +140,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.Ingress.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.Secret != nil { @@ -150,6 +155,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.Secret.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.ConfigMap != nil { @@ -164,6 +170,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.ConfigMap.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.ImagePullSecret != nil { @@ -178,6 +185,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.ImagePullSecret.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.DeploymentStatus != nil { @@ -192,6 +200,9 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + for i := range results { + results[i].Strict = analyzer.DeploymentStatus.Strict.BoolVal + } return results, nil } if analyzer.StatefulsetStatus != nil { @@ -206,6 +217,9 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + for i := range results { + results[i].Strict = analyzer.StatefulsetStatus.Strict.BoolVal + } return results, nil } if analyzer.JobStatus != nil { @@ -220,6 +234,9 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + for i := range results { + results[i].Strict = analyzer.JobStatus.Strict.BoolVal + } return results, nil } if analyzer.ReplicaSetStatus != nil { @@ -234,6 +251,9 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + for i := range results { + results[i].Strict = analyzer.ReplicaSetStatus.Strict.BoolVal + } return results, nil } if analyzer.ClusterPodStatuses != nil { @@ -248,6 +268,9 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + for i := range results { + results[i].Strict = analyzer.ClusterPodStatuses.Strict.BoolVal + } return results, nil } if analyzer.ContainerRuntime != nil { @@ -262,6 +285,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.ContainerRuntime.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.Distribution != nil { @@ -276,6 +300,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.Distribution.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.NodeResources != nil { @@ -290,6 +315,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.NodeResources.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.TextAnalyze != nil { @@ -300,11 +326,14 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if isExcluded { return nil, nil } - multiResult, err := analyzeTextAnalyze(analyzer.TextAnalyze, findFiles) + results, err := analyzeTextAnalyze(analyzer.TextAnalyze, findFiles) if err != nil { return nil, err } - return multiResult, nil + for i := range results { + results[i].Strict = analyzer.TextAnalyze.Strict.BoolVal + } + return results, nil } if analyzer.Postgres != nil { isExcluded, err := isExcluded(analyzer.Postgres.Exclude) @@ -318,6 +347,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.Postgres.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.Mysql != nil { @@ -332,6 +362,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.Mysql.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.Redis != nil { @@ -346,6 +377,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.Redis.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.CephStatus != nil { @@ -360,6 +392,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.CephStatus.Strict.BoolVal return []*AnalyzeResult{result}, nil } if analyzer.Longhorn != nil { @@ -370,7 +403,14 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if isExcluded { return nil, nil } - return longhorn(analyzer.Longhorn, getFile, findFiles) + results, err := longhorn(analyzer.Longhorn, getFile, findFiles) + if err != nil { + return nil, err + } + for i := range results { + results[i].Strict = analyzer.Longhorn.Strict.BoolVal + } + return results, nil } if analyzer.RegistryImages != nil { @@ -385,6 +425,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + result.Strict = analyzer.RegistryImages.Strict.BoolVal return []*AnalyzeResult{result}, nil } @@ -400,6 +441,9 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if err != nil { return nil, err } + for i := range results { + results[i].Strict = analyzer.WeaveReport.Strict.BoolVal + } return results, nil } @@ -418,6 +462,7 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont if result == nil { return []*AnalyzeResult{}, nil } + result.Strict = analyzer.Sysctl.Strict.BoolVal return []*AnalyzeResult{result}, nil } diff --git a/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go b/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go index ac3417aa..844c27db 100644 --- a/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go @@ -177,6 +177,7 @@ type SysctlAnalyze struct { type AnalyzeMeta struct { CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"` Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"` + Strict multitype.BoolOrString `json:"strict,omitempty" yaml:"strict,omitempty"` } type Analyze struct { diff --git a/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go b/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go index 708bb2b5..d8df308c 100644 --- a/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go +++ b/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go @@ -216,6 +216,7 @@ func (in *AnalyzeConfigMap) DeepCopy() *AnalyzeConfigMap { func (in *AnalyzeMeta) DeepCopyInto(out *AnalyzeMeta) { *out = *in out.Exclude = in.Exclude + out.Strict = in.Strict } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnalyzeMeta. diff --git a/pkg/preflight/types.go b/pkg/preflight/types.go index f4b3a9e7..6c051e00 100644 --- a/pkg/preflight/types.go +++ b/pkg/preflight/types.go @@ -1,6 +1,7 @@ package preflight type UploadPreflightResult struct { + Strict bool `json:"strict,omitempty"` IsFail bool `json:"isFail,omitempty"` IsWarn bool `json:"isWarn,omitempty"` IsPass bool `json:"isPass,omitempty"` diff --git a/schemas/analyzer-troubleshoot-v1beta2.json b/schemas/analyzer-troubleshoot-v1beta2.json index b2ec7c59..b1ce564e 100644 --- a/schemas/analyzer-troubleshoot-v1beta2.json +++ b/schemas/analyzer-troubleshoot-v1beta2.json @@ -90,13 +90,15 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, "clusterPodStatuses": { "type": "object", "required": [ - "namespaces", "outcomes" ], "properties": { @@ -161,6 +163,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -225,6 +230,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -300,6 +308,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -364,6 +375,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -432,6 +446,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -439,7 +456,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -455,6 +471,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -504,6 +526,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -568,6 +593,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -636,6 +664,9 @@ }, "registryName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -708,6 +739,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -715,7 +749,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -731,6 +764,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -780,6 +819,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -851,6 +893,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -922,6 +967,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1026,6 +1074,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1097,6 +1148,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1168,6 +1222,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1236,6 +1293,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1243,7 +1303,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes", "selector" ], @@ -1260,6 +1319,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -1315,6 +1380,9 @@ "items": { "type": "string" } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1390,6 +1458,9 @@ }, "secretName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1397,7 +1468,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -1413,6 +1483,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -1462,6 +1538,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1530,6 +1609,9 @@ }, "storageClassName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1594,6 +1676,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1673,6 +1758,9 @@ }, "regexGroups": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1690,6 +1778,9 @@ }, "reportFileGlob": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } } diff --git a/schemas/preflight-troubleshoot-v1beta2.json b/schemas/preflight-troubleshoot-v1beta2.json index 98a3037d..2c11a756 100644 --- a/schemas/preflight-troubleshoot-v1beta2.json +++ b/schemas/preflight-troubleshoot-v1beta2.json @@ -90,13 +90,15 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, "clusterPodStatuses": { "type": "object", "required": [ - "namespaces", "outcomes" ], "properties": { @@ -161,6 +163,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -225,6 +230,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -300,6 +308,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -364,6 +375,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -432,6 +446,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -439,7 +456,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -455,6 +471,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -504,6 +526,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -568,6 +593,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -636,6 +664,9 @@ }, "registryName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -708,6 +739,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -715,7 +749,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -731,6 +764,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -780,6 +819,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -851,6 +893,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -922,6 +967,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1026,6 +1074,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1097,6 +1148,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1168,6 +1222,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1236,6 +1293,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1243,7 +1303,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes", "selector" ], @@ -1260,6 +1319,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -1315,6 +1380,9 @@ "items": { "type": "string" } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1390,6 +1458,9 @@ }, "secretName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1397,7 +1468,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -1413,6 +1483,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -1462,6 +1538,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1530,6 +1609,9 @@ }, "storageClassName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1594,6 +1676,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1673,6 +1758,9 @@ }, "regexGroups": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1690,6 +1778,9 @@ }, "reportFileGlob": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } } diff --git a/schemas/supportbundle-troubleshoot-v1beta2.json b/schemas/supportbundle-troubleshoot-v1beta2.json index 45e6c7bf..97d85ce7 100644 --- a/schemas/supportbundle-troubleshoot-v1beta2.json +++ b/schemas/supportbundle-troubleshoot-v1beta2.json @@ -136,13 +136,15 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, "clusterPodStatuses": { "type": "object", "required": [ - "namespaces", "outcomes" ], "properties": { @@ -207,6 +209,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -271,6 +276,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -346,6 +354,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -410,6 +421,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -478,6 +492,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -485,7 +502,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -501,6 +517,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -550,6 +572,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -614,6 +639,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -682,6 +710,9 @@ }, "registryName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -754,6 +785,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -761,7 +795,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -777,6 +810,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -826,6 +865,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -897,6 +939,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -968,6 +1013,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1072,6 +1120,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1143,6 +1194,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1214,6 +1268,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1282,6 +1339,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1289,7 +1349,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes", "selector" ], @@ -1306,6 +1365,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -1361,6 +1426,9 @@ "items": { "type": "string" } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1436,6 +1504,9 @@ }, "secretName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1443,7 +1514,6 @@ "type": "object", "required": [ "name", - "namespace", "outcomes" ], "properties": { @@ -1459,6 +1529,12 @@ "namespace": { "type": "string" }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, "outcomes": { "type": "array", "items": { @@ -1508,6 +1584,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1576,6 +1655,9 @@ }, "storageClassName": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1640,6 +1722,9 @@ } } } + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1719,6 +1804,9 @@ }, "regexGroups": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }, @@ -1736,6 +1824,9 @@ }, "reportFileGlob": { "type": "string" + }, + "strict": { + "oneOf": [{"type": "string"},{"type": "boolean"}] } } }