From 7eb6263dc1eec7f53dd7fbddf07c90f31ea4cc91 Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Wed, 18 May 2022 10:23:25 +0200 Subject: [PATCH 1/9] Template messages in outcome block for textAnalyzer --- pkg/analyze/text_analyze.go | 34 ++++++++++++++++++++++++++++--- pkg/analyze/text_analyze_test.go | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/pkg/analyze/text_analyze.go b/pkg/analyze/text_analyze.go index f7119084..85d37ee1 100644 --- a/pkg/analyze/text_analyze.go +++ b/pkg/analyze/text_analyze.go @@ -1,11 +1,13 @@ package analyzer import ( + "bytes" "fmt" "path/filepath" "regexp" "strconv" "strings" + "text/template" "github.com/pkg/errors" troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" @@ -169,7 +171,11 @@ func analyzeRegexGroups(pattern string, collected []byte, outcomes []*troublesho if isMatch { result.IsFail = true - result.Message = outcome.Fail.Message + tplMessage, err := templateRegExGroup(outcome.Fail.Message, foundMatches) + if err != nil { + return result, errors.Wrap(err, "failed to template message in outcome.Fail block") + } + result.Message = tplMessage result.URI = outcome.Fail.URI return result, nil @@ -182,7 +188,11 @@ func analyzeRegexGroups(pattern string, collected []byte, outcomes []*troublesho if isMatch { result.IsWarn = true - result.Message = outcome.Warn.Message + tplMessage, err := templateRegExGroup(outcome.Warn.Message, foundMatches) + if err != nil { + return result, errors.Wrap(err, "failed to template message in outcome.Warn block") + } + result.Message = tplMessage result.URI = outcome.Warn.URI return result, nil @@ -195,7 +205,11 @@ func analyzeRegexGroups(pattern string, collected []byte, outcomes []*troublesho if isMatch { result.IsPass = true - result.Message = outcome.Pass.Message + tplMessage, err := templateRegExGroup(outcome.Pass.Message, foundMatches) + if err != nil { + return result, errors.Wrap(err, "failed to template message in outcome.Pass block") + } + result.Message = tplMessage result.URI = outcome.Pass.URI return result, nil @@ -206,6 +220,20 @@ func analyzeRegexGroups(pattern string, collected []byte, outcomes []*troublesho return result, nil } +// templateRegExGroup takes a tpl and replaces the variables using matches. +func templateRegExGroup(tpl string, matches map[string]string) (string, error) { + t, err := template.New("").Parse(tpl) + if err != nil { + return "", err + } + var msg bytes.Buffer + err = t.Execute(&msg, matches) + if err != nil { + panic(err) + } + return msg.String(), nil +} + func compareRegex(conditional string, foundMatches map[string]string) (bool, error) { if conditional == "" { return true, nil diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index 51f036f0..3de6a71b 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -477,6 +477,41 @@ func Test_textAnalyze(t *testing.T) { "text-collector-1/cfile-1.txt": []byte("value: 2\nother: 10"), }, }, + { + name: "Outcome message is templated with regex groups", + analyzer: troubleshootv1beta2.TextAnalyze{ + Outcomes: []*troubleshootv1beta2.Outcome{ + { + Pass: &troubleshootv1beta2.SingleOutcome{ + When: `Error == ""`, + Message: "No error found", + }, + }, + { + Fail: &troubleshootv1beta2.SingleOutcome{ + Message: "There is a prefix not found error in {{ .SubName }} in namespace {{ .Namespace }}", + }, + }, + }, + CollectorName: "text-collector-templated-regex-message", + FileName: "cfile-1.txt", + RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*error":\s*.*"(?Pprefix not found.*?)"`, + }, + expectResult: []AnalyzeResult{ + { + IsPass: false, + IsWarn: false, + IsFail: true, + Title: "text-collector-templated-regex-message", + Message: "There is a prefix not found error in wrong-eventtypeprefix in namespace default", + IconKey: "kubernetes_text_analyze", + IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", + }, + }, + files: map[string][]byte{ + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"wrong-eventtypeprefix","namespace":"default","error":"prefix not found"}}`), + }, + }, } for _, test := range tests { From 5967105ad2c70dabc2a5bf580de404fcd4d6c49f Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 15:35:47 +0200 Subject: [PATCH 2/9] Make test data more generic --- pkg/analyze/text_analyze_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index 3de6a71b..07843e6e 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -489,13 +489,13 @@ func Test_textAnalyze(t *testing.T) { }, { Fail: &troubleshootv1beta2.SingleOutcome{ - Message: "There is a prefix not found error in {{ .SubName }} in namespace {{ .Namespace }}", + Message: "Error for CRD with name in {{ .CRDName }} in namespace {{ .Namespace }}", }, }, }, CollectorName: "text-collector-templated-regex-message", FileName: "cfile-1.txt", - RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*error":\s*.*"(?Pprefix not found.*?)"`, + RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*error":\s*.*"(?Pmyerror.*?)"`, }, expectResult: []AnalyzeResult{ { @@ -503,13 +503,13 @@ func Test_textAnalyze(t *testing.T) { IsWarn: false, IsFail: true, Title: "text-collector-templated-regex-message", - Message: "There is a prefix not found error in wrong-eventtypeprefix in namespace default", + Message: "Error for CRD with name in insert-crd-name-here in namespace default", IconKey: "kubernetes_text_analyze", IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", }, }, files: map[string][]byte{ - "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"wrong-eventtypeprefix","namespace":"default","error":"prefix not found"}}`), + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-crd-name-here","namespace":"default","error":"myerror"}}`), }, }, } From 3ceffbc4b2dcac5baaad7553cac119945b3dc7ee Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 15:45:22 +0200 Subject: [PATCH 3/9] Add test for warn outcome block --- pkg/analyze/text_analyze_test.go | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index 07843e6e..05bb75dd 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -477,6 +477,41 @@ func Test_textAnalyze(t *testing.T) { "text-collector-1/cfile-1.txt": []byte("value: 2\nother: 10"), }, }, + { + name: "Warn message is templated with regex groups", + analyzer: troubleshootv1beta2.TextAnalyze{ + Outcomes: []*troubleshootv1beta2.Outcome{ + { + Pass: &troubleshootv1beta2.SingleOutcome{ + When: `Warning == ""`, + Message: "No warning found", + }, + }, + { + Warn: &troubleshootv1beta2.SingleOutcome{ + Message: "Warning for CRD with name in {{ .CRDName }} in namespace {{ .Namespace }}", + }, + }, + }, + CollectorName: "text-collector-templated-regex-message", + FileName: "cfile-1.txt", + RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*warning":\s*.*"(?Pmywarning.*?)"`, + }, + expectResult: []AnalyzeResult{ + { + IsPass: false, + IsWarn: true, + IsFail: false, + Title: "text-collector-templated-regex-message", + Message: "Warning for CRD with name in insert-crd-name-here in namespace default", + IconKey: "kubernetes_text_analyze", + IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", + }, + }, + files: map[string][]byte{ + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-crd-name-here","namespace":"default","warning":"mywarning"}}`), + }, + }, { name: "Outcome message is templated with regex groups", analyzer: troubleshootv1beta2.TextAnalyze{ From c5505bc01770cb608397142840b64b8784748557 Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 15:47:19 +0200 Subject: [PATCH 4/9] Rename tests --- pkg/analyze/text_analyze_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index 05bb75dd..b59c2280 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -478,7 +478,7 @@ func Test_textAnalyze(t *testing.T) { }, }, { - name: "Warn message is templated with regex groups", + name: "Outcome warn message is templated with regex groups", analyzer: troubleshootv1beta2.TextAnalyze{ Outcomes: []*troubleshootv1beta2.Outcome{ { @@ -513,7 +513,7 @@ func Test_textAnalyze(t *testing.T) { }, }, { - name: "Outcome message is templated with regex groups", + name: "Outcome fail message is templated with regex groups", analyzer: troubleshootv1beta2.TextAnalyze{ Outcomes: []*troubleshootv1beta2.Outcome{ { From a9df4552b4885a44fc4d5570931f389a493f3301 Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 15:52:46 +0200 Subject: [PATCH 5/9] Use warn log level in warn test --- pkg/analyze/text_analyze_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index b59c2280..fcf56bea 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -509,7 +509,7 @@ func Test_textAnalyze(t *testing.T) { }, }, files: map[string][]byte{ - "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-crd-name-here","namespace":"default","warning":"mywarning"}}`), + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"WARN","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-crd-name-here","namespace":"default","warning":"mywarning"}}`), }, }, { From 9179dc8fec0572666ea3c12e0b8a17412f056490 Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 16:40:31 +0200 Subject: [PATCH 6/9] Add test for pass outcome black --- pkg/analyze/text_analyze_test.go | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index fcf56bea..26b21258 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -477,6 +477,38 @@ func Test_textAnalyze(t *testing.T) { "text-collector-1/cfile-1.txt": []byte("value: 2\nother: 10"), }, }, + // This test ensures that the Outcomes.Pass.Message can be templated using the findings of the regular expression groups. + { + name: "Outcome pass message is templated with regex groups", + analyzer: troubleshootv1beta2.TextAnalyze{ + Outcomes: []*troubleshootv1beta2.Outcome{ + { + Pass: &troubleshootv1beta2.SingleOutcome{ + When: `Feature == insert-feature-name-here`, + Message: "Feature {{ .Feature }} is enabled", + }, + }, + }, + CollectorName: "text-collector-templated-regex-message", + FileName: "cfile-1.txt", + RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*feature":\s*.*"(?Pinsert-feature-name-here.*?)"`, + }, + expectResult: []AnalyzeResult{ + { + IsPass: true, + IsWarn: false, + IsFail: false, + Title: "text-collector-templated-regex-message", + Message: "Feature insert-feature-name-here is enabled", + IconKey: "kubernetes_text_analyze", + IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", + }, + }, + files: map[string][]byte{ + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"INFO","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Feature enabled","context":{"name":"insert-crd-name-here","namespace":"default","feature":"insert-feature-name-here"}}`), + }, + }, + // This test ensures that the Outcomes.Warn.Message can be templated using the findings of the regular expression groups. { name: "Outcome warn message is templated with regex groups", analyzer: troubleshootv1beta2.TextAnalyze{ @@ -487,6 +519,7 @@ func Test_textAnalyze(t *testing.T) { Message: "No warning found", }, }, + // The Warn case is triggered if warning != "" { Warn: &troubleshootv1beta2.SingleOutcome{ Message: "Warning for CRD with name in {{ .CRDName }} in namespace {{ .Namespace }}", @@ -512,6 +545,7 @@ func Test_textAnalyze(t *testing.T) { "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"WARN","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-crd-name-here","namespace":"default","warning":"mywarning"}}`), }, }, + // This test ensures that the Outcomes.Fail.Message can be templated using the findings of the regular expression groups. { name: "Outcome fail message is templated with regex groups", analyzer: troubleshootv1beta2.TextAnalyze{ @@ -522,6 +556,7 @@ func Test_textAnalyze(t *testing.T) { Message: "No error found", }, }, + // The Fail case is triggered if warning != "" { Fail: &troubleshootv1beta2.SingleOutcome{ Message: "Error for CRD with name in {{ .CRDName }} in namespace {{ .Namespace }}", From 44c07c2a00f9a7abba1f72b48a462ed3304c8761 Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 17:13:14 +0200 Subject: [PATCH 7/9] Rename CRD -> CR --- pkg/analyze/text_analyze_test.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index 26b21258..4580fa4b 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -485,13 +485,13 @@ func Test_textAnalyze(t *testing.T) { { Pass: &troubleshootv1beta2.SingleOutcome{ When: `Feature == insert-feature-name-here`, - Message: "Feature {{ .Feature }} is enabled", + Message: "Feature {{ .Feature }} is enabled for CR {{ .CRName }} in namespace {{ .Namespace }}", }, }, }, CollectorName: "text-collector-templated-regex-message", FileName: "cfile-1.txt", - RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*feature":\s*.*"(?Pinsert-feature-name-here.*?)"`, + RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*feature":\s*.*"(?Pinsert-feature-name-here.*?)"`, }, expectResult: []AnalyzeResult{ { @@ -499,13 +499,13 @@ func Test_textAnalyze(t *testing.T) { IsWarn: false, IsFail: false, Title: "text-collector-templated-regex-message", - Message: "Feature insert-feature-name-here is enabled", + Message: "Feature insert-feature-name-here is enabled for CR insert-cr-name-here in namespace default", IconKey: "kubernetes_text_analyze", IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", }, }, files: map[string][]byte{ - "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"INFO","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Feature enabled","context":{"name":"insert-crd-name-here","namespace":"default","feature":"insert-feature-name-here"}}`), + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"INFO","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Feature enabled","context":{"name":"insert-cr-name-here","namespace":"default","feature":"insert-feature-name-here"}}`), }, }, // This test ensures that the Outcomes.Warn.Message can be templated using the findings of the regular expression groups. @@ -522,13 +522,13 @@ func Test_textAnalyze(t *testing.T) { // The Warn case is triggered if warning != "" { Warn: &troubleshootv1beta2.SingleOutcome{ - Message: "Warning for CRD with name in {{ .CRDName }} in namespace {{ .Namespace }}", + Message: "Warning for CR with name in {{ .CRName }} in namespace {{ .Namespace }}", }, }, }, CollectorName: "text-collector-templated-regex-message", FileName: "cfile-1.txt", - RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*warning":\s*.*"(?Pmywarning.*?)"`, + RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*warning":\s*.*"(?Pmywarning.*?)"`, }, expectResult: []AnalyzeResult{ { @@ -536,13 +536,13 @@ func Test_textAnalyze(t *testing.T) { IsWarn: true, IsFail: false, Title: "text-collector-templated-regex-message", - Message: "Warning for CRD with name in insert-crd-name-here in namespace default", + Message: "Warning for CR with name in insert-cr-name-here in namespace default", IconKey: "kubernetes_text_analyze", IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", }, }, files: map[string][]byte{ - "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"WARN","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-crd-name-here","namespace":"default","warning":"mywarning"}}`), + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"WARN","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-cr-name-here","namespace":"default","warning":"mywarning"}}`), }, }, // This test ensures that the Outcomes.Fail.Message can be templated using the findings of the regular expression groups. @@ -559,13 +559,13 @@ func Test_textAnalyze(t *testing.T) { // The Fail case is triggered if warning != "" { Fail: &troubleshootv1beta2.SingleOutcome{ - Message: "Error for CRD with name in {{ .CRDName }} in namespace {{ .Namespace }}", + Message: "Error for CR with name in {{ .CRName }} in namespace {{ .Namespace }}", }, }, }, CollectorName: "text-collector-templated-regex-message", FileName: "cfile-1.txt", - RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*error":\s*.*"(?Pmyerror.*?)"`, + RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*error":\s*.*"(?Pmyerror.*?)"`, }, expectResult: []AnalyzeResult{ { @@ -573,13 +573,13 @@ func Test_textAnalyze(t *testing.T) { IsWarn: false, IsFail: true, Title: "text-collector-templated-regex-message", - Message: "Error for CRD with name in insert-crd-name-here in namespace default", + Message: "Error for CR with name in insert-cr-name-here in namespace default", IconKey: "kubernetes_text_analyze", IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", }, }, files: map[string][]byte{ - "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-crd-name-here","namespace":"default","error":"myerror"}}`), + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-cr-name-here","namespace":"default","error":"myerror"}}`), }, }, } From 8adf58b71785e857ad20a85c3ef1a2110f262a92 Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 17:23:22 +0200 Subject: [PATCH 8/9] Return err instead of panic --- pkg/analyze/text_analyze.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/analyze/text_analyze.go b/pkg/analyze/text_analyze.go index 85d37ee1..2179ac3e 100644 --- a/pkg/analyze/text_analyze.go +++ b/pkg/analyze/text_analyze.go @@ -229,7 +229,7 @@ func templateRegExGroup(tpl string, matches map[string]string) (string, error) { var msg bytes.Buffer err = t.Execute(&msg, matches) if err != nil { - panic(err) + return "", err } return msg.String(), nil } From 3d6841c11e92037c10532d27ffe559346230ad09 Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 17:27:50 +0200 Subject: [PATCH 9/9] Fix typos --- pkg/analyze/text_analyze_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index 4580fa4b..5fc4527e 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -522,7 +522,7 @@ func Test_textAnalyze(t *testing.T) { // The Warn case is triggered if warning != "" { Warn: &troubleshootv1beta2.SingleOutcome{ - Message: "Warning for CR with name in {{ .CRName }} in namespace {{ .Namespace }}", + Message: "Warning for CR with name {{ .CRName }} in namespace {{ .Namespace }}", }, }, }, @@ -536,7 +536,7 @@ func Test_textAnalyze(t *testing.T) { IsWarn: true, IsFail: false, Title: "text-collector-templated-regex-message", - Message: "Warning for CR with name in insert-cr-name-here in namespace default", + Message: "Warning for CR with name insert-cr-name-here in namespace default", IconKey: "kubernetes_text_analyze", IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", }, @@ -559,7 +559,7 @@ func Test_textAnalyze(t *testing.T) { // The Fail case is triggered if warning != "" { Fail: &troubleshootv1beta2.SingleOutcome{ - Message: "Error for CR with name in {{ .CRName }} in namespace {{ .Namespace }}", + Message: "Error for CR with name {{ .CRName }} in namespace {{ .Namespace }}", }, }, }, @@ -573,7 +573,7 @@ func Test_textAnalyze(t *testing.T) { IsWarn: false, IsFail: true, Title: "text-collector-templated-regex-message", - Message: "Error for CR with name in insert-cr-name-here in namespace default", + Message: "Error for CR with name insert-cr-name-here in namespace default", IconKey: "kubernetes_text_analyze", IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", },