Commit 1aa9629
feat(cel): enable string and list extension functions in CEL expressions
Previously, CEL expressions in Pipelines-as-Code only had access to
the core CEL operators, which limited users to basic comparisons and
logical expressions. Functions like join(), replace(), substring(),
and other string/list manipulation operations were unavailable,
forcing users to work around these limitations.
This adds cel-go's ext.Strings() and ext.Lists() extensions to the
CEL environment in pkg/cel/cel.go. This unlocks the full set of
standard CEL string operations (join, replace, substring, split,
trim, upperAscii, lowerAscii, etc.) and list operations, which can
be used in both `on-cel-expression` annotations and `{{ cel: }}`
template expressions.
Changes:
- pkg/cel/cel.go: Register ext.Strings() and ext.Lists() extensions
on the CEL environment alongside existing variable declarations
- pkg/templates/templating_test.go: Add unit tests for join(),
replace(), and substring() via the template placeholder path;
improve test failure message to show actual vs expected values
- test/testdata/pipelinerun-cel-string-join.yaml: New e2e test
fixture that uses files.all.join(", ") in a cel: template
- test/github_pullrequest_test.go: Add GHE e2e test
(TestGithubGHEPullRequestCELJoin) that verifies join() works
end-to-end by checking the PipelineRun pod log output matches
the expected changed file path
Note: The e2e test uses regex matching (empty goldenFile param)
rather than golden file comparison, since the output is a single
dynamic file path that varies per test run.
Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 861a507 commit 1aa9629
46 files changed
Lines changed: 16015 additions & 3 deletions
File tree
- pkg
- cel
- templates
- test
- testdata
- vendor
- github.com/google/cel-go/ext
- golang.org/x/text
- feature/plural
- internal
- catmsg
- format
- number
- stringset
- message
- catalog
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
93 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
94 | 98 | | |
95 | 99 | | |
96 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
178 | 225 | | |
179 | 226 | | |
180 | 227 | | |
181 | 228 | | |
182 | 229 | | |
183 | | - | |
| 230 | + | |
184 | 231 | | |
185 | 232 | | |
186 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
765 | 765 | | |
766 | 766 | | |
767 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
768 | 796 | | |
769 | 797 | | |
770 | 798 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments