Skip to content

Commit 11c3b61

Browse files
committed
Account for whitespace chomping character
Some of our RegEx expressions didn't account for the `-}}` syntax Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
1 parent 12b08a1 commit 11c3b61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: pkg/templates/templates.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ func (t *TemplateResolver) processForDataTypes(str string) string {
789789
d1 := regexp.QuoteMeta(t.config.StartDelim)
790790
d2 := regexp.QuoteMeta(t.config.StopDelim)
791791
//nolint: lll
792-
expression := `:\s+(?:[\|>]-?\s+)?(?:'?\s*)(` + d1 + `(?:.*\|\s*(?:toInt|toBool|toLiteral)|(?:.*(?:copyConfigMapData|copySecretData))).*` + d2 + `)(?:\s*'?)`
792+
expression := `:\s+(?:[\|>]-?\s+)?(?:'?\s*)(` + d1 + `-?(?:.*\|\s*(?:toInt|toBool|toLiteral)|(?:.*(?:copyConfigMapData|copySecretData))).*` + d2 + `)(?:\s*'?)`
793793
re := regexp.MustCompile(expression)
794794
klog.V(2).Infof("\n Pattern: %v\n", re.String())
795795

@@ -815,7 +815,7 @@ func (t *TemplateResolver) processForAutoIndent(str string) string {
815815
// This is not a very strict regex as occasionally, a user will make a mistake such as
816816
// `config: '{{ "hello\nworld" | autoindent }}'`. In that event, `autoindent` will change to
817817
// `indent 1`, but `indent` properly handles this.
818-
re := regexp.MustCompile(`( *)(?:'|")?(` + d1 + `.*\| *autoindent *` + d2 + `)`)
818+
re := regexp.MustCompile(`( *)(?:'|")?(` + d1 + `.*\| *autoindent *-?` + d2 + `)`)
819819
klog.V(2).Infof("\n Pattern: %v\n", re.String())
820820

821821
submatches := re.FindAllStringSubmatch(str, -1)

0 commit comments

Comments
 (0)