forked from project-flogo/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop.go
33 lines (28 loc) · 866 Bytes
/
loop.go
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
package resolve
import (
"fmt"
"github.com/qingcloudhx/core/data"
"github.com/qingcloudhx/core/data/path"
)
var loopResolverInfo = NewImplicitResolverInfo(false, true)
type LoopResolver struct {
}
func (*LoopResolver) GetResolverInfo() *ResolverInfo {
return loopResolverInfo
}
//LoopResolver Loop Resolver $Loop[item]
func (*LoopResolver) Resolve(scope data.Scope, item string, field string) (interface{}, error) {
if item == "" {
v, exist := scope.GetValue(field)
if !exist {
return nil, fmt.Errorf("failed to resolve current Loop: '%s', ensure that Loop is configured in the application", field)
}
return v, nil
} else {
value, exists := scope.GetValue(item)
if !exists {
return nil, fmt.Errorf("failed to resolve Loop: '%s', ensure that Loop is configured in the application", item)
}
return path.GetValue(value, "."+field)
}
}