Skip to content

Commit 5a849b1

Browse files
Merge pull request #5 from actionforge/group-secret-inputs
Resolve input secrets in group nodes and update e2e tests
2 parents 15bc9fc + 162b417 commit 5a849b1

12 files changed

Lines changed: 314 additions & 46 deletions

core/inputs.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,19 @@ func (n *Inputs) InputValueById(ec *ExecutionState, host NodeWithInputs, inputId
435435
if !inputDefExists {
436436
inputDef, inputDefExists = n.inputDefs[inputId]
437437
}
438-
if inputDefExists && inputDef.Type == "option" {
439-
switch c := finalValue.(type) {
440-
case string:
441-
finalValue = strings.Trim(c, " \n\r")
442-
case int8, int16, int32, int64, int, uint8, uint16, uint32, uint64, uint:
443-
nv := reflect.ValueOf(c).Int()
444-
if len(inputDef.Options) > 0 && int(nv) >= len(inputDef.Options) {
445-
return nil, CreateErr(ec, nil, "option value out of range: %v", nv)
438+
if inputDefExists {
439+
switch inputDef.Type {
440+
case "option":
441+
switch c := finalValue.(type) {
442+
case string:
443+
finalValue = strings.Trim(c, " \n\r")
444+
case int8, int16, int32, int64, int, uint8, uint16, uint32, uint64, uint:
445+
nv := reflect.ValueOf(c).Int()
446+
if len(inputDef.Options) > 0 && int(nv) >= len(inputDef.Options) {
447+
return nil, CreateErr(ec, nil, "option value out of range: %v", nv)
448+
}
449+
finalValue = inputDef.Options[nv].Value
446450
}
447-
finalValue = inputDef.Options[nv].Value
448451
}
449452
}
450453

nodes/group@v1.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,36 @@ type GroupNode struct {
2020
}
2121

2222
func (n *GroupNode) OutputValueById(c *core.ExecutionState, outputId core.OutputId) (any, error) {
23-
v, err := n.InputValueById(c, n, core.InputId(outputId), nil)
24-
if err != nil {
25-
return nil, err
23+
24+
var (
25+
err error
26+
v any
27+
)
28+
29+
// Nodes are responsible for resolving secrets, so is the group node if the secret input name
30+
// is coming from the group node itself. Like the other nodes, secrets are empty if not found.
31+
_, connected := n.GetDataSource(core.InputId(outputId))
32+
if !connected {
33+
inputDef, _, inputDefExists := n.Inputs.InputDefByPortId(string(outputId))
34+
if inputDefExists && inputDef.Type == "secret" {
35+
v, err = core.InputValueById[core.SecretValue](c, n, core.InputId(outputId))
36+
if err != nil {
37+
if strings.HasPrefix(err.Error(), "no secret found for") {
38+
// empty secrets are ignored, similar to the core/secret-get node
39+
// since the caller is responsible for checking the value
40+
v = ""
41+
} else {
42+
return nil, err
43+
}
44+
}
45+
}
46+
}
47+
48+
if v == nil {
49+
v, err = n.InputValueById(c, n, core.InputId(outputId), nil)
50+
if err != nil {
51+
return nil, err
52+
}
2653
}
2754

2855
return v, nil

tests_e2e/references/reference_error_no_output.sh_l8

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ github.com/actionforge/actrun-cli/core.(*Outputs).OutputValueById
3737
github.com/actionforge/actrun-cli/core.(*Inputs).InputValueById
3838
inputs.go:364
3939
github.com/actionforge/actrun-cli/core.inputValueById[...]
40-
inputs.go:475
40+
inputs.go:478
4141
github.com/actionforge/actrun-cli/core.InputValueFromSubInputs[...]
42-
inputs.go:470
42+
inputs.go:473
4343
github.com/actionforge/actrun-cli/core.InputArrayValueById[...]
44-
inputs.go:552
44+
inputs.go:555
4545
github.com/actionforge/actrun-cli/nodes.(*PrintNode).ExecuteImpl
4646
print@v1.go:27
4747
github.com/actionforge/actrun-cli/core.(*Executions).Execute

tests_e2e/references/reference_group-error.sh_l8

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ github.com/actionforge/actrun-cli/nodes.(*GroupInputsNode).ExecuteImpl
138138
github.com/actionforge/actrun-cli/core.(*Executions).Execute
139139
executions.go:56
140140
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
141-
group@v1.go:75
141+
group@v1.go:102
142142
github.com/actionforge/actrun-cli/core.(*Executions).Execute
143143
executions.go:56
144144
github.com/actionforge/actrun-cli/nodes.(*PrintNode).ExecuteImpl
145145
print@v1.go:103
146146
github.com/actionforge/actrun-cli/core.(*Executions).Execute
147147
executions.go:56
148148
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
149-
group@v1.go:75
149+
group@v1.go:102
150150
github.com/actionforge/actrun-cli/core.(*Executions).Execute
151151
executions.go:56
152152
github.com/actionforge/actrun-cli/nodes.(*GroupOutputsNode).ExecuteImpl
@@ -162,23 +162,23 @@ github.com/actionforge/actrun-cli/nodes.(*GroupInputsNode).ExecuteImpl
162162
github.com/actionforge/actrun-cli/core.(*Executions).Execute
163163
executions.go:56
164164
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
165-
group@v1.go:75
165+
group@v1.go:102
166166
github.com/actionforge/actrun-cli/core.(*Executions).Execute
167167
executions.go:56
168168
github.com/actionforge/actrun-cli/nodes.(*PrintNode).ExecuteImpl
169169
print@v1.go:103
170170
github.com/actionforge/actrun-cli/core.(*Executions).Execute
171171
executions.go:56
172172
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
173-
group@v1.go:75
173+
group@v1.go:102
174174
github.com/actionforge/actrun-cli/core.(*Executions).Execute
175175
executions.go:56
176176
github.com/actionforge/actrun-cli/nodes.(*GroupOutputsNode).ExecuteImpl
177177
group-outputs@v1.go:30
178178
github.com/actionforge/actrun-cli/core.(*Executions).Execute
179179
executions.go:56
180180
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
181-
group@v1.go:75
181+
group@v1.go:102
182182
github.com/actionforge/actrun-cli/core.(*Executions).Execute
183183
executions.go:56
184184
github.com/actionforge/actrun-cli/nodes.(*GroupOutputsNode).ExecuteImpl
@@ -194,31 +194,31 @@ github.com/actionforge/actrun-cli/nodes.(*GroupInputsNode).ExecuteImpl
194194
github.com/actionforge/actrun-cli/core.(*Executions).Execute
195195
executions.go:56
196196
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
197-
group@v1.go:75
197+
group@v1.go:102
198198
github.com/actionforge/actrun-cli/core.(*Executions).Execute
199199
executions.go:56
200200
github.com/actionforge/actrun-cli/nodes.(*GroupInputsNode).ExecuteImpl
201201
group-inputs@v1.go:39
202202
github.com/actionforge/actrun-cli/core.(*Executions).Execute
203203
executions.go:56
204204
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
205-
group@v1.go:75
205+
group@v1.go:102
206206
github.com/actionforge/actrun-cli/core.(*Executions).Execute
207207
executions.go:56
208208
github.com/actionforge/actrun-cli/nodes.(*PrintNode).ExecuteImpl
209209
print@v1.go:103
210210
github.com/actionforge/actrun-cli/core.(*Executions).Execute
211211
executions.go:56
212212
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
213-
group@v1.go:75
213+
group@v1.go:102
214214
github.com/actionforge/actrun-cli/core.(*Executions).Execute
215215
executions.go:56
216216
github.com/actionforge/actrun-cli/nodes.(*GroupOutputsNode).ExecuteImpl
217217
group-outputs@v1.go:30
218218
github.com/actionforge/actrun-cli/core.(*Executions).Execute
219219
executions.go:56
220220
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
221-
group@v1.go:75
221+
group@v1.go:102
222222
github.com/actionforge/actrun-cli/core.(*Executions).Execute
223223
executions.go:56
224224
github.com/actionforge/actrun-cli/nodes.(*GroupOutputsNode).ExecuteImpl
@@ -234,15 +234,15 @@ github.com/actionforge/actrun-cli/nodes.(*GroupInputsNode).ExecuteImpl
234234
github.com/actionforge/actrun-cli/core.(*Executions).Execute
235235
executions.go:56
236236
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
237-
group@v1.go:75
237+
group@v1.go:102
238238
github.com/actionforge/actrun-cli/core.(*Executions).Execute
239239
executions.go:56
240240
github.com/actionforge/actrun-cli/nodes.(*GroupInputsNode).ExecuteImpl
241241
group-inputs@v1.go:39
242242
github.com/actionforge/actrun-cli/core.(*Executions).Execute
243243
executions.go:56
244244
github.com/actionforge/actrun-cli/nodes.(*GroupNode).ExecuteImpl
245-
group@v1.go:75
245+
group@v1.go:102
246246
github.com/actionforge/actrun-cli/core.(*Executions).Execute
247247
executions.go:56
248248
github.com/actionforge/actrun-cli/nodes.(*StartNode).ExecuteImpl

tests_e2e/references/reference_group-port-collision.sh_l13

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ error:
2121

2222
stack trace:
2323
github.com/actionforge/actrun-cli/nodes.init.39.func1
24-
group@v1.go:128
24+
group@v1.go:155
2525
github.com/actionforge/actrun-cli/core.NewNodeInstance
2626
base.go:610
2727
github.com/actionforge/actrun-cli/core.LoadNode

tests_e2e/references/reference_index.sh_l20

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ github.com/actionforge/actrun-cli/nodes.(*ArrayGet).OutputValueById
6666
github.com/actionforge/actrun-cli/core.(*Inputs).InputValueById
6767
inputs.go:364
6868
github.com/actionforge/actrun-cli/core.inputValueById[...]
69-
inputs.go:475
69+
inputs.go:478
7070
github.com/actionforge/actrun-cli/core.InputValueFromSubInputs[...]
71-
inputs.go:470
71+
inputs.go:473
7272
github.com/actionforge/actrun-cli/core.InputArrayValueById[...]
73-
inputs.go:552
73+
inputs.go:555
7474
github.com/actionforge/actrun-cli/nodes.(*PrintNode).ExecuteImpl
7575
print@v1.go:27
7676
github.com/actionforge/actrun-cli/core.(*Executions).Execute

tests_e2e/references/reference_secret.sh_l12

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,30 @@ PushNodeVisit: secret-v1-orange-blueberry-red, execute: false
2121
PushNodeVisit: core-secret-get-v1-duck-starfruit-silver, execute: false
2222
THIS_IS_A_SECRET_FROM_BASH
2323
THIS_IS_A_SECRET_2_FROM_BASH
24+
🟢 Execute 'Print (core-print-v1-plum-pink-green)'
25+
PushNodeVisit: core-print-v1-plum-pink-green, execute: true
26+
PushNodeVisit: core-secret-get-v1-navy-coconut-black, execute: false
27+
28+
🟢 Execute 'Set Secret (core-secret-set-v1-purple-strawberry-parrot)'
29+
PushNodeVisit: core-secret-set-v1-purple-strawberry-parrot, execute: true
30+
🟢 Execute 'Print (core-print-v1-dragonfruit-hippopotamus-blackberry)'
31+
PushNodeVisit: core-print-v1-dragonfruit-hippopotamus-blackberry, execute: true
32+
PushNodeVisit: core-secret-get-v1-pineapple-navy-maroon, execute: false
33+
my-set-secret
34+
🟢 Execute 'Group (core-group-v1-sheep-papaya-date)'
35+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: true
36+
🟢 Execute 'Group Inputs (core-group-inputs-v1-goose-boysenberry-pineapple)'
37+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: true
38+
🟢 Execute 'Print (core-print-v1-snake-green-turquoise)'
39+
PushNodeVisit: core-print-v1-snake-green-turquoise, execute: true
40+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: false
41+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: false
42+
PushNodeVisit: core-secret-get-v1-pineapple-navy-maroon, execute: false
43+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: false
44+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: false
45+
my-set-secret
46+
{my-set-secret}
47+
🟢 Execute 'Group Output (core-group-outputs-v1-parrot-purple-shark)'
48+
PushNodeVisit: core-group-outputs-v1-parrot-purple-shark, execute: true
49+
🟢 Execute 'Group (core-group-v1-sheep-papaya-date)'
50+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: true

tests_e2e/references/reference_secret.sh_l17

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,30 @@ PushNodeVisit: secret-v1-orange-blueberry-red, execute: false
2121
PushNodeVisit: core-secret-get-v1-duck-starfruit-silver, execute: false
2222
THIS_IS_ANOTHER_SECRET_FROM_BASH
2323
THIS_IS_ANOTHER_SECRET_2_FROM_BASH
24+
🟢 Execute 'Print (core-print-v1-plum-pink-green)'
25+
PushNodeVisit: core-print-v1-plum-pink-green, execute: true
26+
PushNodeVisit: core-secret-get-v1-navy-coconut-black, execute: false
27+
28+
🟢 Execute 'Set Secret (core-secret-set-v1-purple-strawberry-parrot)'
29+
PushNodeVisit: core-secret-set-v1-purple-strawberry-parrot, execute: true
30+
🟢 Execute 'Print (core-print-v1-dragonfruit-hippopotamus-blackberry)'
31+
PushNodeVisit: core-print-v1-dragonfruit-hippopotamus-blackberry, execute: true
32+
PushNodeVisit: core-secret-get-v1-pineapple-navy-maroon, execute: false
33+
my-set-secret
34+
🟢 Execute 'Group (core-group-v1-sheep-papaya-date)'
35+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: true
36+
🟢 Execute 'Group Inputs (core-group-inputs-v1-goose-boysenberry-pineapple)'
37+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: true
38+
🟢 Execute 'Print (core-print-v1-snake-green-turquoise)'
39+
PushNodeVisit: core-print-v1-snake-green-turquoise, execute: true
40+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: false
41+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: false
42+
PushNodeVisit: core-secret-get-v1-pineapple-navy-maroon, execute: false
43+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: false
44+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: false
45+
my-set-secret
46+
{my-set-secret}
47+
🟢 Execute 'Group Output (core-group-outputs-v1-parrot-purple-shark)'
48+
PushNodeVisit: core-group-outputs-v1-parrot-purple-shark, execute: true
49+
🟢 Execute 'Group (core-group-v1-sheep-papaya-date)'
50+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: true

tests_e2e/references/reference_secret.sh_l21

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,30 @@ PushNodeVisit: secret-v1-orange-blueberry-red, execute: false
2222
PushNodeVisit: core-secret-get-v1-duck-starfruit-silver, execute: false
2323
THIS_IS_API_KEY_123_FROM_SECRET_ACTCONFIG
2424
ALIAS_FROM_SECRET_ACTCONFIG
25+
🟢 Execute 'Print (core-print-v1-plum-pink-green)'
26+
PushNodeVisit: core-print-v1-plum-pink-green, execute: true
27+
PushNodeVisit: core-secret-get-v1-navy-coconut-black, execute: false
28+
29+
🟢 Execute 'Set Secret (core-secret-set-v1-purple-strawberry-parrot)'
30+
PushNodeVisit: core-secret-set-v1-purple-strawberry-parrot, execute: true
31+
🟢 Execute 'Print (core-print-v1-dragonfruit-hippopotamus-blackberry)'
32+
PushNodeVisit: core-print-v1-dragonfruit-hippopotamus-blackberry, execute: true
33+
PushNodeVisit: core-secret-get-v1-pineapple-navy-maroon, execute: false
34+
my-set-secret
35+
🟢 Execute 'Group (core-group-v1-sheep-papaya-date)'
36+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: true
37+
🟢 Execute 'Group Inputs (core-group-inputs-v1-goose-boysenberry-pineapple)'
38+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: true
39+
🟢 Execute 'Print (core-print-v1-snake-green-turquoise)'
40+
PushNodeVisit: core-print-v1-snake-green-turquoise, execute: true
41+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: false
42+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: false
43+
PushNodeVisit: core-secret-get-v1-pineapple-navy-maroon, execute: false
44+
PushNodeVisit: core-group-inputs-v1-goose-boysenberry-pineapple, execute: false
45+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: false
46+
my-set-secret
47+
{my-set-secret}
48+
🟢 Execute 'Group Output (core-group-outputs-v1-parrot-purple-shark)'
49+
PushNodeVisit: core-group-outputs-v1-parrot-purple-shark, execute: true
50+
🟢 Execute 'Group (core-group-v1-sheep-papaya-date)'
51+
PushNodeVisit: core-group-v1-sheep-papaya-date, execute: true

tests_e2e/references/reference_select-data.sh_l9

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ github.com/actionforge/actrun-cli/nodes.(*SelectDataNode).OutputValueById
7373
github.com/actionforge/actrun-cli/core.(*Inputs).InputValueById
7474
inputs.go:364
7575
github.com/actionforge/actrun-cli/core.inputValueById[...]
76-
inputs.go:475
76+
inputs.go:478
7777
github.com/actionforge/actrun-cli/core.InputValueFromSubInputs[...]
78-
inputs.go:470
78+
inputs.go:473
7979
github.com/actionforge/actrun-cli/core.InputArrayValueById[...]
80-
inputs.go:552
80+
inputs.go:555
8181
github.com/actionforge/actrun-cli/nodes.(*PrintNode).ExecuteImpl
8282
print@v1.go:27
8383
github.com/actionforge/actrun-cli/core.(*Executions).Execute

0 commit comments

Comments
 (0)