-
Notifications
You must be signed in to change notification settings - Fork 78
/
type.go
38 lines (32 loc) · 863 Bytes
/
type.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
package compile
import (
kcl "kusionstack.io/kclvm-go"
"kusionstack.io/kusion/pkg/util/yaml"
)
// The result of a KCL compilation
type CompileResult struct {
Documents []kcl.KCLResult
}
// New a CompileResult by KCLResultList
func NewCompileResult(k *kcl.KCLResultList) *CompileResult {
return &CompileResult{
Documents: k.Slice(),
}
}
// New a CompileResult by map array
func NewCompileResultByMapList(mapList []map[string]interface{}) *CompileResult {
documents := []kcl.KCLResult{}
for _, mapItem := range mapList {
documents = append(documents, kcl.KCLResult(mapItem))
}
return &CompileResult{
Documents: documents,
}
}
func (c *CompileResult) YAMLString() string {
documentList := []interface{}{}
for _, document := range c.Documents {
documentList = append(documentList, document)
}
return yaml.MergeToOneYAML(documentList...)
}