|
@@ -46,14 +46,14 @@ spec:
|
|
|
supplied: {}`
|
|
|
|
|
|
type Flow struct {
|
|
|
- Name string
|
|
|
- ChildNodes []Node
|
|
|
+ name string
|
|
|
+ childNodes []Node
|
|
|
}
|
|
|
|
|
|
func NewFlow(name string, childNodes ...Node) *Flow {
|
|
|
return &Flow{
|
|
|
- Name: name,
|
|
|
- ChildNodes: childNodes,
|
|
|
+ name: name,
|
|
|
+ childNodes: childNodes,
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -65,9 +65,17 @@ func (flow *Flow) GetWhen() string {
|
|
|
return ""
|
|
|
}
|
|
|
|
|
|
+func (flow *Flow) AddNodes(childNodes ...Node) *Flow {
|
|
|
+ if childNodes == nil || len(childNodes) == 0 {
|
|
|
+ flow.childNodes = append(flow.childNodes, childNodes...)
|
|
|
+ }
|
|
|
+
|
|
|
+ return flow
|
|
|
+}
|
|
|
+
|
|
|
func (flow *Flow) Render(_ Node) (string, error) {
|
|
|
childNodesContents := make([]string, 0)
|
|
|
- for i, childNode := range flow.ChildNodes {
|
|
|
+ for i, childNode := range flow.childNodes {
|
|
|
var childNodeContent string
|
|
|
|
|
|
if i == 0 {
|
|
@@ -78,7 +86,7 @@ func (flow *Flow) Render(_ Node) (string, error) {
|
|
|
|
|
|
childNodeContent = content
|
|
|
} else {
|
|
|
- content, err := childNode.Render(flow.ChildNodes[i-1])
|
|
|
+ content, err := childNode.Render(flow.childNodes[i-1])
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
@@ -90,7 +98,7 @@ func (flow *Flow) Render(_ Node) (string, error) {
|
|
|
}
|
|
|
|
|
|
return render("flow", flowTemplate, map[string]any{
|
|
|
- "name": flow.Name,
|
|
|
+ "name": flow.name,
|
|
|
"childNodesContentLines": childNodesContents,
|
|
|
})
|
|
|
}
|