Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit e92cde6

Browse files
alexcodelfthxCode
authored andcommitted
fix: support hyphen in workflow variables
1 parent bd6c0ee commit e92cde6

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

pkg/dao/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func parseWorkflowVariables(
353353
return nil, err
354354
}
355355

356-
re := regexp.MustCompile(`\$\{\s*workflow\.var\.(\w+)\s*\}`)
356+
re := regexp.MustCompile(`\$\{\s*workflow\.var\.([-\w]+)\s*}`)
357357
replaced := re.ReplaceAllFunc(bs, func(s []byte) []byte {
358358
name := re.FindSubmatch(s)[1]
359359
name = bytes.TrimSpace(name)

pkg/dao/workflow_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,41 @@ func TestParseParams(t *testing.T) {
3434
},
3535
wantError: false,
3636
},
37+
{
38+
attributes: map[string]any{
39+
"description": "${workflow.var.var-1}",
40+
},
41+
params: map[string]string{
42+
"var-1": "aaa",
43+
},
44+
config: types.WorkflowVariables{
45+
{
46+
Name: "var-1",
47+
Value: "alice",
48+
Overwrite: true,
49+
},
50+
},
51+
expected: map[string]any{
52+
"description": "aaa",
53+
},
54+
wantError: false,
55+
},
56+
{
57+
attributes: map[string]any{
58+
"description": "${workflow.var.var-1}",
59+
},
60+
config: types.WorkflowVariables{
61+
{
62+
Name: "var-1",
63+
Value: "alice",
64+
Overwrite: false,
65+
},
66+
},
67+
expected: map[string]any{
68+
"description": "alice",
69+
},
70+
wantError: false,
71+
},
3772
{
3873
attributes: map[string]any{
3974
"deepAttr": map[string]any{

0 commit comments

Comments
 (0)