diff --git a/pkg/api/nodes.go b/pkg/api/nodes.go index 99d8568f..ae3d0fec 100755 --- a/pkg/api/nodes.go +++ b/pkg/api/nodes.go @@ -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 @@ -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 diff --git a/pkg/reactor/manifest_resolver.go b/pkg/reactor/manifest_resolver.go index cb694890..a6ca1122 100644 --- a/pkg/reactor/manifest_resolver.go +++ b/pkg/reactor/manifest_resolver.go @@ -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