Skip to content

Commit

Permalink
Add envcontain to template string evaluation (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitrise-silver authored Nov 7, 2023
1 parent a20cb04 commit 636e6d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bitrise/template_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func EvaluateTemplateToString(expStr string, isCI, isPR bool, buildResults model
"enveq": func(key, expectedValue string) bool {
return (getEnv(key, envList) == expectedValue)
},
"envcontain": func(key, subString string) bool {
return strings.Contains(getEnv(key, envList), subString)
},
}

tmpl := template.New("EvaluateTemplateToBool").Funcs(templateFuncMap)
Expand Down
10 changes: 10 additions & 0 deletions bitrise/template_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ func TestRegisteredFunctions(t *testing.T) {
envValue: "enveq value",
expected: false,
},
{
propTempCont: `{{envcontain "TEST_KEY" "val"}}`,
envValue: "enveq value",
expected: true,
},
{
propTempCont: `{{envcontain "TEST_KEY" "different"}}`,
envValue: "enveq value",
expected: false,
},
}
for _, test := range tests {
t.Run(test.propTempCont, func(t *testing.T) {
Expand Down

0 comments on commit 636e6d0

Please sign in to comment.