Skip to content

Commit

Permalink
256 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kostov6 committed Dec 9, 2021
1 parent c3a04a0 commit cd6315b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"

"gopkg.in/yaml.v3"
"k8s.io/klog/v2"
)

// Parent returns the parent node (if any) of this node n
Expand Down Expand Up @@ -267,7 +268,8 @@ func (n *Node) Union(nodes []*Node) error {
continue // same node
}
if node.isDocument() {
return fmt.Errorf("not a container node to merge in %s/%s", Path(existingNode, "/"), existingNode.Name)
klog.Warningf("%s is not a container node that tried to merge in %s/%s", node.Name, Path(existingNode, "/"), existingNode.Name)
return nil
}
if len(node.Nodes) > 0 {
// merge recursively
Expand Down
13 changes: 12 additions & 1 deletion pkg/reactor/manifest_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,18 @@ func resolveStructure(ctx context.Context, rhRegistry resourcehandlers.Registry,
if err = node.Union(newNode.Nodes); err != nil {
return err
}
node.Parent().Nodes = node.Nodes
// remove node form node.Parent().Nodes
parentNodes := node.Parent().Nodes
for index, el := range parentNodes {
if el == node {
parentNodes[index] = parentNodes[len(parentNodes)-1]
node.Parent().Nodes = parentNodes[:len(parentNodes)-1]
}
}
//merge node.Nodes with node.Parent().Nodes
if err = node.Parent().Union(node.Nodes); err != nil {
return err
}
} else {
if err = node.Union(newNode.Nodes); err != nil {
return err
Expand Down

0 comments on commit cd6315b

Please sign in to comment.