Skip to content

Commit 5162da3

Browse files
committed
refactor: replace templating and eval with jahvon/expression pkg
1 parent fbbfbf1 commit 5162da3

File tree

23 files changed

+95
-687
lines changed

23 files changed

+95
-687
lines changed

desktop/src-tauri/src/types/generated/template.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub mod error {
4242
#[doc = " ],"]
4343
#[doc = " \"properties\": {"]
4444
#[doc = " \"asTemplate\": {"]
45-
#[doc = " \"description\": \"If true, the artifact will be copied as a template file. The file will be rendered using Go templating from \\nthe form data. [Sprig functions](https://masterminds.github.io/sprig/) are available for use in the template.\\n\","]
45+
#[doc = " \"description\": \"If true, the artifact will be copied as a template file. The file will be rendered using Go templating from \\nthe form data. [Expr language functions](https://expr-lang.org/docs/language-definition) are available for use in the template.\\n\","]
4646
#[doc = " \"default\": false,"]
4747
#[doc = " \"type\": \"boolean\""]
4848
#[doc = " },"]
@@ -76,7 +76,7 @@ pub mod error {
7676
#[doc = r" </details>"]
7777
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
7878
pub struct Artifact {
79-
#[doc = "If true, the artifact will be copied as a template file. The file will be rendered using Go templating from \nthe form data. [Sprig functions](https://masterminds.github.io/sprig/) are available for use in the template.\n"]
79+
#[doc = "If true, the artifact will be copied as a template file. The file will be rendered using Go templating from \nthe form data. [Expr language functions](https://expr-lang.org/docs/language-definition) are available for use in the template.\n"]
8080
#[serde(rename = "asTemplate", default)]
8181
pub as_template: bool,
8282
#[doc = "The directory to copy the file to. If not set, the file will be copied to the root of the flow file directory.\nThe directory will be created if it does not exist.\n"]

desktop/src/types/generated/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface Template {
4040
export interface Artifact {
4141
/**
4242
* If true, the artifact will be copied as a template file. The file will be rendered using Go templating from
43-
* the form data. [Sprig functions](https://masterminds.github.io/sprig/) are available for use in the template.
43+
* the form data. [Expr language functions](https://expr-lang.org/docs/language-definition) are available for use in the template.
4444
*
4545
*/
4646
asTemplate?: boolean;

docs/guide/advanced.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ The expression language supports standard comparison and logical operators:
1616
- String: `+` (concatenation), `matches` (regex matching)
1717
- Length: `len()`
1818

19+
See the [Expr Language Definition](https://expr-lang.org/docs/language-definition) for all available operators and functions.
20+
1921
### Basic Conditions <!-- {docsify-ignore} -->
2022

2123
Use the `if` field to control when executables run:

docs/guide/executables.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ executables:
327327
- `method`: HTTP method (GET, POST, PUT, PATCH, DELETE)
328328
- `url`: Request URL (required)
329329
- `headers`: Custom headers
330-
- `body`: Request body
330+
- `body`: Request body with Expr templating
331331
- `timeout`: Request timeout
332332
- `validStatusCodes`: Acceptable status codes
333333
- `logResponse`: Log response body
334-
- `transformResponse`: Transform response with Expr
334+
- `transformResponse`: Transform response with Expr templating
335335
- `responseFile`: Save response to file
336336

337337
### render - Dynamic Documentation
@@ -351,16 +351,16 @@ executables:
351351
```markdown
352352
# System Status
353353
354-
Current time: {{ .timestamp }}
354+
Current time: {{ data["timestamp"] }}
355355
356356
## Services
357357
{{- range .services }}
358-
- **{{ .name }}**: {{ .status }}
358+
- **{{ .name }}**: {{ data["status"] }}
359359
{{- end }}
360360
361361
## Metrics
362-
- CPU: {{ .cpu }}%
363-
- Memory: {{ .memory }}%
362+
- CPU: {{ data["cpu"] }}%
363+
- Memory: {{ data["memory"] }}%
364364
```
365365

366366
**Options:**

docs/schemas/template_schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"properties": {
1818
"asTemplate": {
19-
"description": "If true, the artifact will be copied as a template file. The file will be rendered using Go templating from \nthe form data. [Sprig functions](https://masterminds.github.io/sprig/) are available for use in the template.\n",
19+
"description": "If true, the artifact will be copied as a template file. The file will be rendered using Go templating from \nthe form data. [Expr language functions](https://expr-lang.org/docs/language-definition) are available for use in the template.\n",
2020
"type": "boolean",
2121
"default": false
2222
},

docs/types/template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Go templating from form data is supported in all fields.
3636

3737
| Field | Description | Type | Default | Required |
3838
| ----- | ----------- | ---- | ------- | :--------: |
39-
| `asTemplate` | If true, the artifact will be copied as a template file. The file will be rendered using Go templating from the form data. [Sprig functions](https://masterminds.github.io/sprig/) are available for use in the template. | `boolean` | false | |
39+
| `asTemplate` | If true, the artifact will be copied as a template file. The file will be rendered using Go templating from the form data. [Expr language functions](https://expr-lang.org/docs/language-definition) are available for use in the template. | `boolean` | false | |
4040
| `dstDir` | The directory to copy the file to. If not set, the file will be copied to the root of the flow file directory. The directory will be created if it does not exist. | `string` | | |
4141
| `dstName` | The name of the file to copy to. If not set, the file will be copied with the same name. | `string` | | |
4242
| `if` | An expression that determines whether the the artifact should be copied, using the Expr language syntax. The expression is evaluated at runtime and must resolve to a boolean value. If the condition is not met, the artifact will not be copied. The expression has access to OS/architecture information (os, arch), environment variables (env), form input (form), and context information (name, workspace, directory, etc.). See the [flow documentation](https://flowexec.io/guide/templating) for more information. | `string` | | |

go.mod

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ module github.com/flowexec/flow
33
go 1.24.0
44

55
require (
6-
github.com/Masterminds/sprig/v3 v3.3.0
76
github.com/atotto/clipboard v0.1.4
87
github.com/charmbracelet/bubbles v0.21.0
98
github.com/charmbracelet/bubbletea v1.3.6
109
github.com/charmbracelet/lipgloss v1.1.0
1110
github.com/charmbracelet/x/exp/teatest v0.0.0-20250806222409-83e3a29d542f
12-
github.com/expr-lang/expr v1.17.5
1311
github.com/flowexec/tuikit v0.2.3
1412
github.com/flowexec/vault v0.1.2
1513
github.com/gen2brain/beeep v0.11.1
14+
github.com/jahvon/expression v0.1.3
1615
github.com/jahvon/glamour v0.8.1-patch3
1716
github.com/mark3labs/mcp-go v0.37.0
1817
github.com/mattn/go-runewidth v0.0.16
@@ -33,11 +32,8 @@ require (
3332
)
3433

3534
require (
36-
dario.cat/mergo v1.0.2 // indirect
3735
filippo.io/age v1.2.1 // indirect
3836
git.sr.ht/~jackmordaunt/go-toast v1.1.2 // indirect
39-
github.com/Masterminds/goutils v1.1.1 // indirect
40-
github.com/Masterminds/semver/v3 v3.4.0 // indirect
4137
github.com/alecthomas/chroma/v2 v2.20.0 // indirect
4238
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
4339
github.com/aymanbagabas/go-udiff v0.3.1 // indirect
@@ -58,6 +54,7 @@ require (
5854
github.com/dustin/go-humanize v1.0.1 // indirect
5955
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
6056
github.com/esiqveland/notify v0.13.3 // indirect
57+
github.com/expr-lang/expr v1.17.5 // indirect
6158
github.com/go-logfmt/logfmt v0.6.0 // indirect
6259
github.com/go-logr/logr v1.4.3 // indirect
6360
github.com/go-ole/go-ole v1.3.0 // indirect
@@ -67,7 +64,6 @@ require (
6764
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5 // indirect
6865
github.com/google/uuid v1.6.0 // indirect
6966
github.com/gorilla/css v1.0.1 // indirect
70-
github.com/huandu/xstrings v1.5.0 // indirect
7167
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7268
github.com/invopop/jsonschema v0.13.0 // indirect
7369
github.com/jackmordaunt/icns/v3 v3.0.1 // indirect
@@ -76,9 +72,7 @@ require (
7672
github.com/mattn/go-isatty v0.0.20 // indirect
7773
github.com/mattn/go-localereader v0.0.1 // indirect
7874
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
79-
github.com/mitchellh/copystructure v1.2.0 // indirect
8075
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
81-
github.com/mitchellh/reflectwalk v1.0.2 // indirect
8276
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
8377
github.com/muesli/cancelreader v0.2.2 // indirect
8478
github.com/muesli/reflow v0.3.0 // indirect
@@ -89,7 +83,6 @@ require (
8983
github.com/sahilm/fuzzy v0.1.1 // indirect
9084
github.com/sergeymakinen/go-bmp v1.0.0 // indirect
9185
github.com/sergeymakinen/go-ico v1.0.0-beta.0 // indirect
92-
github.com/shopspring/decimal v1.4.0 // indirect
9386
github.com/spf13/cast v1.9.2 // indirect
9487
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
9588
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect

go.sum

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
c2sp.org/CCTV/age v0.0.0-20240306222714-3ec4d716e805 h1:u2qwJeEvnypw+OCPUHmoZE3IqwfuN5kgDfo5MLzpNM0=
22
c2sp.org/CCTV/age v0.0.0-20240306222714-3ec4d716e805/go.mod h1:FomMrUJ2Lxt5jCLmZkG3FHa72zUprnhd3v/Z18Snm4w=
3-
dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
4-
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
53
filippo.io/age v1.2.1 h1:X0TZjehAZylOIj4DubWYU1vWQxv9bJpo+Uu2/LGhi1o=
64
filippo.io/age v1.2.1/go.mod h1:JL9ew2lTN+Pyft4RiNGguFfOpewKwSHm5ayKD/A4004=
75
git.sr.ht/~jackmordaunt/go-toast v1.1.2 h1:/yrfI55LRt1M7H1vkaw+NaH1+L1CDxrqDltwm5euVuE=
86
git.sr.ht/~jackmordaunt/go-toast v1.1.2/go.mod h1:jA4OqHKTQ4AFBdwrSnwnskUIIS3HYzlJSgdzCKqfavo=
97
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
108
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
11-
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
12-
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
13-
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
14-
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
15-
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
16-
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
179
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
1810
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
1911
github.com/alecthomas/chroma/v2 v2.20.0 h1:sfIHpxPyR07/Oylvmcai3X/exDlE8+FA820NTz+9sGw=
@@ -114,14 +106,14 @@ github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
114106
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
115107
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
116108
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
117-
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
118-
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
119109
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
120110
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
121111
github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=
122112
github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
123113
github.com/jackmordaunt/icns/v3 v3.0.1 h1:xxot6aNuGrU+lNgxz5I5H0qSeCjNKp8uTXB1j8D4S3o=
124114
github.com/jackmordaunt/icns/v3 v3.0.1/go.mod h1:5sHL59nqTd2ynTnowxB/MDQFhKNqkK8X687uKNygaSQ=
115+
github.com/jahvon/expression v0.1.3 h1:ZOH6tj1zK9h+M+eDy/n1Fz6XL/vA3lCV6bzHe6YWAvY=
116+
github.com/jahvon/expression v0.1.3/go.mod h1:4HJB2k+epW5vFeptF6ILlXbFRQ+CuCyCSO4QdnGT3AE=
125117
github.com/jahvon/glamour v0.8.1-patch3 h1:LfyMACZavV8yxK4UsPENNQQOqafWuq4ZdLuEAP2ZLE8=
126118
github.com/jahvon/glamour v0.8.1-patch3/go.mod h1:30MVJwG3rcEHrN277NrA4DKzndSL9lBtEmpcfOygwCQ=
127119
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@@ -145,12 +137,8 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T
145137
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
146138
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
147139
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
148-
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
149-
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
150140
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
151141
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
152-
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
153-
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
154142
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
155143
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
156144
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
@@ -189,8 +177,6 @@ github.com/sergeymakinen/go-bmp v1.0.0 h1:SdGTzp9WvCV0A1V0mBeaS7kQAwNLdVJbmHlqNW
189177
github.com/sergeymakinen/go-bmp v1.0.0/go.mod h1:/mxlAQZRLxSvJFNIEGGLBE/m40f3ZnUifpgVDlcUIEY=
190178
github.com/sergeymakinen/go-ico v1.0.0-beta.0 h1:m5qKH7uPKLdrygMWxbamVn+tl2HfiA3K6MFJw4GfZvQ=
191179
github.com/sergeymakinen/go-ico v1.0.0-beta.0/go.mod h1:wQ47mTczswBO5F0NoDt7O0IXgnV4Xy3ojrroMQzyhUk=
192-
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
193-
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
194180
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
195181
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
196182
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=

internal/mcp/resources/template_schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"properties": {
1818
"asTemplate": {
19-
"description": "If true, the artifact will be copied as a template file. The file will be rendered using Go templating from \nthe form data. [Sprig functions](https://masterminds.github.io/sprig/) are available for use in the template.\n",
19+
"description": "If true, the artifact will be copied as a template file. The file will be rendered using Go templating from \nthe form data. [Expr language functions](https://expr-lang.org/docs/language-definition) are available for use in the template.\n",
2020
"type": "boolean",
2121
"default": false
2222
},

internal/runner/parallel/parallel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88
"path/filepath"
99
"strings"
1010

11+
"github.com/jahvon/expression"
1112
"github.com/pkg/errors"
1213
"golang.org/x/sync/errgroup"
1314

1415
"github.com/flowexec/flow/internal/context"
1516
"github.com/flowexec/flow/internal/logger"
1617
"github.com/flowexec/flow/internal/runner"
1718
"github.com/flowexec/flow/internal/runner/engine"
18-
"github.com/flowexec/flow/internal/services/expr"
1919
"github.com/flowexec/flow/internal/services/store"
2020
envUtils "github.com/flowexec/flow/internal/utils/env"
2121
execUtils "github.com/flowexec/flow/internal/utils/executables"
@@ -127,12 +127,12 @@ func handleExec(
127127

128128
// Build the list of steps to execute
129129
var execs []engine.Exec
130-
conditionalData := expr.ExpressionEnv(ctx, parent, cacheData, inputEnv)
130+
conditionalData := runner.ExpressionEnv(ctx, parent, cacheData, inputEnv)
131131

132132
for i, refConfig := range parallelSpec.Execs {
133133
// Skip over steps that do not match the condition
134134
if refConfig.If != "" {
135-
if truthy, err := expr.IsTruthy(refConfig.If, &conditionalData); err != nil {
135+
if truthy, err := expression.IsTruthy(refConfig.If, conditionalData); err != nil {
136136
return err
137137
} else if !truthy {
138138
logger.Log().Debugf("skipping execution %d/%d", i+1, len(parallelSpec.Execs))

0 commit comments

Comments
 (0)