Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyom committed Jan 22, 2020
1 parent 2881071 commit afcd7b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
17 changes: 16 additions & 1 deletion pkg/template/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func applyEventValuesToParams(params []pipelinev1.Param, body []byte, header htt
for idx, p := range params {
pValue := p.Value.StringVal
// Find all expressions wrapped in $() from the value
expressions := tektonVar.FindAllString(pValue, -1)
expressions := findTektonExpressions(pValue)
for _, expr := range expressions {
val, err := ParseJSONPath(event, expr)
if err != nil {
Expand All @@ -100,3 +100,18 @@ func applyEventValuesToParams(params []pipelinev1.Param, body []byte, header htt
}
return params, nil
}


func findTektonExpressions(pValue string) []string {
results := []string{}
// Splits string on $( to find potential Tekton expressions
s := strings.Split(pValue, "$(")
for _, i := range s {
// Only a Tekton expression if it also contains a ) following the $(
if strings.Contains(i, ")") {
// Extract until the last instance of ) and wrap it in $()
results = append(results, fmt.Sprintf("$(%s)", i[:strings.LastIndex(i, ")")]))
}
}
return results
}
Loading

0 comments on commit afcd7b2

Please sign in to comment.