-
Notifications
You must be signed in to change notification settings - Fork 16
/
node.go
41 lines (34 loc) · 839 Bytes
/
node.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
34
35
36
37
38
39
40
41
package dynaml
import (
"strings"
"github.com/mandelsoft/spiff/yaml"
)
func value(node yaml.Node) interface{} {
if node == nil {
return nil
}
return node.Value()
}
func NewNode(val interface{}, src SourceProvider) yaml.Node {
source := ""
if src == nil || len(src.SourceName()) == 0 {
source = "dynaml"
} else {
if !strings.HasPrefix(src.SourceName(), "dynaml@") {
source = "dynaml@" + src.SourceName()
} else {
source = src.SourceName()
}
}
return yaml.NewNode(val, source)
}
func IssueNode(env Binding, preservePath bool, node yaml.Node, error bool, failed bool, issue yaml.Issue) yaml.Node {
if node.Issue().OrigPath != nil {
issue.OrigPath = node.Issue().OrigPath
} else {
if env != nil && preservePath {
issue.OrigPath = env.Path()
}
}
return yaml.IssueNode(node, error, failed, issue)
}