-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathnode-template.go
59 lines (51 loc) · 1.77 KB
/
node-template.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package normal
import (
"github.com/tliron/go-ard"
)
//
// NodeTemplate
//
type NodeTemplate struct {
ServiceTemplate *ServiceTemplate `json:"-" yaml:"-"`
Name string `json:"-" yaml:"-"`
Metadata map[string]string `json:"metadata" yaml:"metadata"`
Description string `json:"description" yaml:"description"`
Types EntityTypes `json:"types" yaml:"types"`
Directives []string `json:"directives" yaml:"directives"`
Properties Values `json:"properties" yaml:"properties"`
Attributes Values `json:"attributes" yaml:"attributes"`
Requirements Requirements `json:"requirements" yaml:"requirements"`
Capabilities Capabilities `json:"capabilities" yaml:"capabilities"`
Interfaces Interfaces `json:"interfaces" yaml:"interfaces"`
Artifacts Artifacts `json:"artifacts" yaml:"artifacts"`
}
func (self *ServiceTemplate) NewNodeTemplate(name string) *NodeTemplate {
nodeTemplate := &NodeTemplate{
ServiceTemplate: self,
Name: name,
Metadata: make(map[string]string),
Types: make(EntityTypes),
Directives: make([]string, 0),
Properties: make(Values),
Attributes: make(Values),
Requirements: make(Requirements, 0),
Capabilities: make(Capabilities),
Interfaces: make(Interfaces),
Artifacts: make(Artifacts),
}
self.NodeTemplates[name] = nodeTemplate
return nodeTemplate
}
//
// NodeTemplates
//
type NodeTemplates map[string]*NodeTemplate
// For access in JavaScript
func (self NodeTemplates) Object(name string) map[string]any {
// JavaScript requires keys to be strings, so we would lose complex keys
o := make(ard.StringMap)
for key, nodeTemplate := range self {
o[key] = nodeTemplate
}
return o
}