From ae78819389652281c155f25c805aa24465d55141 Mon Sep 17 00:00:00 2001 From: Chitrang Patel <chitrang@google.com> Date: Wed, 11 May 2022 14:18:17 -0400 Subject: [PATCH] Extract parameter name without any firm pattern. We want to extract everything that `NAME` contains in (`$param.<NAME> | $param.<NAME>[*]`) or (`param["<NAME>"] | $param["<NAME>"][*]`) or (`param['NAME'][*] | $param['<NAME>'][*]`). We dont want to enforce the pattern that it should follow. That part should be done by `Step 1` in https://github.com/tektoncd/pipeline/pull/4799#discussion_r859259763 The regex pattern substitution `.*?(\[\*\])?` matches and extracts everything that is contained in `<NAME>` or `<NAME>[*]`. --- pkg/substitution/substitution.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/substitution/substitution.go b/pkg/substitution/substitution.go index e0d07c946f9..156a1ddaf4e 100644 --- a/pkg/substitution/substitution.go +++ b/pkg/substitution/substitution.go @@ -25,8 +25,7 @@ import ( "knative.dev/pkg/apis" ) -const parameterSubstitution = `[_a-zA-Z][_a-zA-Z0-9.-]*(\[\*\])?` - +const parameterSubstitution = `.*?(\[\*\])?` const braceMatchingRegex = "(\\$(\\(%s(\\.(?P<var1>%s)|\\[\"(?P<var2>%s)\"\\]|\\['(?P<var3>%s)'\\])\\)))" // ValidateVariable makes sure all variables in the provided string are known