forked from k1LoW/runn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbind.go
More file actions
36 lines (31 loc) · 862 Bytes
/
Copy pathbind.go
File metadata and controls
36 lines (31 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package runn
import (
"context"
"fmt"
)
const bindRunnerKey = "bind"
type bindRunner struct {
operator *operator
}
func newBindRunner(o *operator) (*bindRunner, error) {
return &bindRunner{
operator: o,
}, nil
}
func (rnr *bindRunner) Run(ctx context.Context, cond map[string]string) error {
store := rnr.operator.store.toMap()
store[storeIncludedKey] = rnr.operator.included
store[storePreviousKey] = rnr.operator.store.previous()
store[storeCurrentKey] = rnr.operator.store.latest()
for k, v := range cond {
if k == storeVarsKey || k == storeStepsKey || k == storeParentKey || k == storeIncludedKey || k == storeCurrentKey || k == storePreviousKey || k == loopCountVarKey {
return fmt.Errorf("'%s' is reserved", k)
}
vv, err := Eval(v, store)
if err != nil {
return err
}
rnr.operator.store.bindVars[k] = vv
}
return nil
}