This repository was archived by the owner on Dec 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnormative_type_implementation.go
80 lines (67 loc) · 2.03 KB
/
normative_type_implementation.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package toscaviewer
import (
"github.com/owulveryck/toscalib"
"log"
"reflect"
)
type ToscaNodesCompute toscalib.NodeTemplate
func (nodeTemplate *ToscaNodesCompute) Create() error {
log.Printf("Running the ToscaNodesCompute's Create method")
if nodeTemplate.Interfaces != nil {
log.Printf("Found Interfaces %v", nodeTemplate.Interfaces)
}
return nil
}
func (nodeTemplate *ToscaNodesCompute) Configure() error {
log.Printf("Running the ToscaNodesCompute's Configure method")
return nil
}
func (nodeTemplate *ToscaNodesCompute) Start() error {
log.Printf("Running the ToscaNodesCompute's Start method")
return nil
}
func (nodeTemplate *ToscaNodesCompute) Stop() error {
log.Printf("Running the ToscaNodesCompute's Stop method")
return nil
}
func (nodeTemplate *ToscaNodesCompute) Delete() error {
log.Printf("Running the ToscaNodesCompute's Delete method")
return nil
}
//DefaultNodeType is set when no other implementation is found
// By default it trigger the artifcat for any method if any interface implementation is found
type DefaultNodeType toscalib.NodeTemplate
func (nodeTemplate *DefaultNodeType) Create() error {
if nodeTemplate.Interfaces != nil {
for _, methods := range nodeTemplate.Interfaces {
for method, value := range methods {
if method == "create" {
v := reflect.ValueOf(value)
if v.Kind() == reflect.Map {
log.Printf("Running %v", value)
} else {
log.Printf("Running %v", value)
}
}
}
}
//log.Printf("Found Interfaces %v", nodeTemplate.Interfaces)
}
return nil
}
func (nodeTemplate *DefaultNodeType) Configure() error {
log.Printf("Running the DefaultNodeType's Configure method")
return nil
}
func (nodeTemplate *DefaultNodeType) Start() error {
log.Printf("Running the DefaultNodeType's Start method")
return nil
}
func (nodeTemplate *DefaultNodeType) Stop() error {
log.Printf("Running the DefaultNodeType's Stop method")
return nil
}
func (nodeTemplate *DefaultNodeType) Delete() error {
log.Printf("Running the DefaultNodeType's Delete method")
return nil
}